@@ -17,6 +17,7 @@ const enum PromptInputState {
17
17
Unknown ,
18
18
Input ,
19
19
Execute ,
20
+ Interrupt ,
20
21
}
21
22
22
23
/**
@@ -125,20 +126,23 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
125
126
this . _value = '' ;
126
127
this . _cursorIndex = 0 ;
127
128
this . _onDidStartInput . fire ( this . _createStateObject ( ) ) ;
129
+ this . _onDidChangeInput . fire ( this . _createStateObject ( ) ) ;
128
130
}
129
131
130
132
private _handleCommandExecuted ( ) {
131
133
if ( this . _state === PromptInputState . Execute ) {
132
134
return ;
133
135
}
134
136
135
- this . _state = PromptInputState . Execute ;
136
137
this . _cursorIndex = - 1 ;
137
138
const event = this . _createStateObject ( ) ;
138
- if ( this . _lastUserInput === '\u0003' ) { // ETX end of text (ctrl+c)
139
+ if ( this . _state === PromptInputState . Interrupt ) {
139
140
this . _onDidInterrupt . fire ( event ) ;
140
141
}
142
+
143
+ this . _state = PromptInputState . Execute ;
141
144
this . _onDidFinishInput . fire ( event ) ;
145
+ this . _onDidChangeInput . fire ( event ) ;
142
146
}
143
147
144
148
@throttle ( 0 )
@@ -212,6 +216,15 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
212
216
this . _logService . trace ( `PromptInputModel#_sync: ${ this . getCombinedString ( ) } ` ) ;
213
217
}
214
218
219
+ // Check for an interrupt, this is verified using both the last user input and the current
220
+ // input.
221
+ if ( this . _lastUserInput === '\u0003' ) { // ETX end of text (ctrl+c)
222
+ if ( this . _value . endsWith ( '^C' ) ) {
223
+ this . _state = PromptInputState . Interrupt ;
224
+ return ;
225
+ }
226
+ }
227
+
215
228
if ( this . _value !== value || this . _cursorIndex !== cursorIndex || this . _ghostTextIndex !== ghostTextIndex ) {
216
229
this . _value = value ;
217
230
this . _cursorIndex = cursorIndex ;
0 commit comments