@@ -14,10 +14,9 @@ import { throttle } from 'vs/base/common/decorators';
14
14
import type { Terminal , IMarker , IBufferCell , IBufferLine , IBuffer } from '@xterm/headless' ;
15
15
16
16
const enum PromptInputState {
17
- Unknown ,
18
- Input ,
19
- Execute ,
20
- Interrupt ,
17
+ Unknown = 0 ,
18
+ Input = 1 ,
19
+ Execute = 2 ,
21
20
}
22
21
23
22
/**
@@ -94,6 +93,18 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
94
93
95
94
this . _register ( onCommandStart ( e => this . _handleCommandStart ( e as { marker : IMarker } ) ) ) ;
96
95
this . _register ( onCommandExecuted ( ( ) => this . _handleCommandExecuted ( ) ) ) ;
96
+
97
+ this . onDidStartInput ( ( ) => this . _logCombinedStringIfTrace ( 'PromptInputModel#onDidStartInput' ) ) ;
98
+ this . onDidChangeInput ( ( ) => this . _logCombinedStringIfTrace ( 'PromptInputModel#onDidChangeInput' ) ) ;
99
+ this . onDidFinishInput ( ( ) => this . _logCombinedStringIfTrace ( 'PromptInputModel#onDidFinishInput' ) ) ;
100
+ this . onDidInterrupt ( ( ) => this . _logCombinedStringIfTrace ( 'PromptInputModel#onDidInterrupt' ) ) ;
101
+ }
102
+
103
+ private _logCombinedStringIfTrace ( message : string ) {
104
+ // Only generate the combined string if trace
105
+ if ( this . _logService . getLevel ( ) === LogLevel . Trace ) {
106
+ this . _logService . trace ( message , this . getCombinedString ( ) ) ;
107
+ }
97
108
}
98
109
99
110
setContinuationPrompt ( value : string ) : void {
@@ -136,7 +147,7 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
136
147
137
148
this . _cursorIndex = - 1 ;
138
149
const event = this . _createStateObject ( ) ;
139
- if ( this . _state === PromptInputState . Interrupt ) {
150
+ if ( this . _lastUserInput !== '\u0003' ) {
140
151
this . _onDidInterrupt . fire ( event ) ;
141
152
}
142
153
@@ -216,15 +227,6 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
216
227
this . _logService . trace ( `PromptInputModel#_sync: ${ this . getCombinedString ( ) } ` ) ;
217
228
}
218
229
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
-
228
230
if ( this . _value !== value || this . _cursorIndex !== cursorIndex || this . _ghostTextIndex !== ghostTextIndex ) {
229
231
this . _value = value ;
230
232
this . _cursorIndex = cursorIndex ;
0 commit comments