@@ -48,7 +48,11 @@ const enum ShellIntegrationOscPs {
48
48
/**
49
49
* Sequences pioneered by iTerm.
50
50
*/
51
- ITerm = 1337
51
+ ITerm = 1337 ,
52
+ /**
53
+ * Sequences by Cmder.
54
+ */
55
+ Cmder = 9
52
56
}
53
57
54
58
/**
@@ -166,6 +170,16 @@ const enum ITermOscPt {
166
170
CurrentDir = 'CurrentDir'
167
171
}
168
172
173
+ /**
174
+ * Cmder sequences
175
+ */
176
+ const enum CmderOscPt {
177
+ /**
178
+ * Reports current working directory (CWD). `OSC 9 ; 9 ; <cwd> ST`
179
+ */
180
+ Code9 = '9'
181
+ }
182
+
169
183
/**
170
184
* The shell integration addon extends xterm by reading shell integration sequences and creating
171
185
* capabilities and passing along relevant sequences to the capabilities. This is meant to
@@ -206,6 +220,7 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
206
220
this . capabilities . add ( TerminalCapability . PartialCommandDetection , new PartialCommandDetectionCapability ( this . _terminal ) ) ;
207
221
this . _register ( xterm . parser . registerOscHandler ( ShellIntegrationOscPs . VSCode , data => this . _handleVSCodeSequence ( data ) ) ) ;
208
222
this . _register ( xterm . parser . registerOscHandler ( ShellIntegrationOscPs . ITerm , data => this . _doHandleITermSequence ( data ) ) ) ;
223
+ this . _register ( xterm . parser . registerOscHandler ( ShellIntegrationOscPs . Cmder , data => this . _doHandleCmderSequence ( data ) ) ) ;
209
224
this . _commonProtocolDisposables . push (
210
225
xterm . parser . registerOscHandler ( ShellIntegrationOscPs . FinalTerm , data => this . _handleFinalTermSequence ( data ) )
211
226
) ;
@@ -343,7 +358,6 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
343
358
case 'Cwd' : {
344
359
// TODO: Ideally we would also support the following to supplement our own:
345
360
// - OSC 7 ; scheme://cwd ST (Unknown origin)
346
- // - OSC 9 ; 9 ; <cwd> ST (cmder)
347
361
this . _updateCwd ( value ) ;
348
362
return true ;
349
363
}
@@ -400,6 +414,24 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
400
414
return false ;
401
415
}
402
416
417
+ private _doHandleCmderSequence ( data : string ) : boolean {
418
+ if ( ! this . _terminal ) {
419
+ return false ;
420
+ }
421
+
422
+ const [ command , ...args ] = data . split ( ';' ) ;
423
+ switch ( command ) {
424
+ case CmderOscPt . Code9 :
425
+ if ( args . length ) {
426
+ this . _updateCwd ( args [ 0 ] ) ;
427
+ }
428
+ return true ;
429
+ }
430
+
431
+ // Unrecognized sequence
432
+ return false ;
433
+ }
434
+
403
435
serialize ( ) : ISerializedCommandDetectionCapability {
404
436
if ( ! this . _terminal || ! this . capabilities . has ( TerminalCapability . CommandDetection ) ) {
405
437
return {
0 commit comments