@@ -141,19 +141,16 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
141
141
return ;
142
142
}
143
143
144
- // Command start line
145
- this . _value = commandLine ;
146
-
147
- // Get cursor index
148
144
const absoluteCursorY = buffer . baseY + buffer . cursorY ;
149
- this . _cursorIndex = absoluteCursorY === commandStartY ? this . _getRelativeCursorIndex ( this . _commandStartX , buffer , line ) : commandLine . length + 1 ;
150
- this . _ghostTextIndex = - 1 ;
145
+ let value = commandLine ;
146
+ let cursorIndex = absoluteCursorY === commandStartY ? this . _getRelativeCursorIndex ( this . _commandStartX , buffer , line ) : commandLine . length + 1 ;
147
+ let ghostTextIndex = - 1 ;
151
148
152
149
// Detect ghost text by looking for italic or dim text in or after the cursor and
153
150
// non-italic/dim text in the cell closest non-whitespace cell before the cursor
154
151
if ( absoluteCursorY === commandStartY && buffer . cursorX > 1 ) {
155
152
// Ghost text in pwsh only appears to happen on the cursor line
156
- this . _ghostTextIndex = this . _scanForGhostText ( buffer , line ) ;
153
+ ghostTextIndex = this . _scanForGhostText ( buffer , line ) ;
157
154
}
158
155
159
156
// IDEA: Detect line continuation if it's not set
@@ -167,8 +164,8 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
167
164
// user likely just pressed enter
168
165
if ( this . _continuationPrompt === undefined || this . _lineContainsContinuationPrompt ( lineText ) ) {
169
166
lineText = this . _trimContinuationPrompt ( lineText ) ;
170
- this . _value += `\n${ lineText } ` ;
171
- this . _cursorIndex += ( absoluteCursorY === y
167
+ value += `\n${ lineText } ` ;
168
+ cursorIndex += ( absoluteCursorY === y
172
169
? this . _getRelativeCursorIndex ( this . _getContinuationPromptCellWidth ( line , lineText ) , buffer , line )
173
170
: lineText . length + 1 ) ;
174
171
} else {
@@ -183,7 +180,7 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
183
180
const lineText = line ?. translateToString ( true ) ;
184
181
if ( lineText && line ) {
185
182
if ( this . _continuationPrompt === undefined || this . _lineContainsContinuationPrompt ( lineText ) ) {
186
- this . _value += `\n${ this . _trimContinuationPrompt ( lineText ) } ` ;
183
+ value += `\n${ this . _trimContinuationPrompt ( lineText ) } ` ;
187
184
} else {
188
185
break ;
189
186
}
@@ -194,7 +191,12 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
194
191
this . _logService . trace ( `PromptInputModel#_sync: ${ this . getCombinedString ( ) } ` ) ;
195
192
}
196
193
197
- this . _onDidChangeInput . fire ( ) ;
194
+ if ( this . _value !== value || this . _cursorIndex !== cursorIndex || this . _ghostTextIndex !== ghostTextIndex ) {
195
+ this . _value = value ;
196
+ this . _cursorIndex = cursorIndex ;
197
+ this . _ghostTextIndex = ghostTextIndex ;
198
+ this . _onDidChangeInput . fire ( ) ;
199
+ }
198
200
}
199
201
200
202
/**
0 commit comments