File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
common/capabilities/commandDetection
test/common/capabilities/commandDetection Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -217,16 +217,18 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
217
217
// Check to the end of the line for possible ghost text. For example pwsh's ghost text
218
218
// can look like this `Get-|Ch[ildItem]`
219
219
if ( proceedWithGhostTextCheck ) {
220
+ let potentialGhostIndexOffset = 0 ;
220
221
let x = buffer . cursorX ;
221
222
while ( x < line . length ) {
222
223
const cell = line . getCell ( x ++ ) ;
223
224
if ( ! cell || cell . getCode ( ) === 0 ) {
224
225
break ;
225
226
}
226
227
if ( this . _isCellStyledLikeGhostText ( cell ) ) {
227
- ghostTextIndex = this . _cursorIndex ;
228
+ ghostTextIndex = this . _cursorIndex + potentialGhostIndexOffset ;
228
229
break ;
229
230
}
231
+ potentialGhostIndexOffset += cell . getChars ( ) . length ;
230
232
}
231
233
}
232
234
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ suite('PromptInputModel', () => {
48
48
49
49
const actualValueWithCursor = promptInputModel . getCombinedString ( ) ;
50
50
strictEqual (
51
- actualValueWithCursor . replaceAll ( '\n' , '\u23CE' ) ,
51
+ actualValueWithCursor ,
52
52
valueWithCursor . replaceAll ( '\n' , '\u23CE' )
53
53
) ;
54
54
@@ -110,6 +110,18 @@ suite('PromptInputModel', () => {
110
110
assertPromptInput ( 'foo bar|' ) ;
111
111
} ) ;
112
112
113
+ test ( 'ghost text' , async ( ) => {
114
+ await writePromise ( '$ ' ) ;
115
+ fireCommandStart ( ) ;
116
+ assertPromptInput ( '|' ) ;
117
+
118
+ await writePromise ( 'foo\x1b[2m bar\x1b[0m\x1b[4D' ) ;
119
+ assertPromptInput ( 'foo|[ bar]' ) ;
120
+
121
+ await writePromise ( '\x1b[2D' ) ;
122
+ assertPromptInput ( 'f|oo[ bar]' ) ;
123
+ } ) ;
124
+
113
125
test ( 'wide input (Korean)' , async ( ) => {
114
126
await writePromise ( '$ ' ) ;
115
127
fireCommandStart ( ) ;
You can’t perform that action at this time.
0 commit comments