561
return -1;
562
}
564
>
for (let i = 1; i < positionsWithGhostStyle.length; i++) {
565
>
if (positionsWithGhostStyle[i] !== positionsWithGhostStyle[i - 1] + 1) {
566
// Discontinuous styles, so may be syntax highlighting vs ghost text
567
return -1;
568
}
570
>
// Calculate the ghost text start index
571
if (buffer.baseY + buffer.cursorY === this._commandStartMarker?.line) {
573
>
} else {
574
ghostTextIndex = positionsWithGhostStyle[0];
575
}
576
}
578
>
// Ensure no earlier cells in the line match `lastNonWhitespaceCell`'s style,
579
>
// which would indicate the text is not ghost text.
580
>
if (ghostTextIndex !== -1) {
581
>
for (let checkPos = buffer.cursorX; checkPos >= this._commandStartX; checkPos--) {
582
>
const checkCell = line.getCell(checkPos);
583
>
if (!checkCell?.getChars.length) {
584
>
continue;
585
>
}
586
>
if (checkCell && checkCell.getCode() !== 0 && this._cellStylesMatch(lastNonWhitespaceCell, checkCell)) {
587
return -1;
588
}
590
>
}
591
>
592
return ghostTextIndex >= cursorIndex ? ghostTextIndex : -1;
593
}