@@ -49,14 +49,8 @@ const enum ShellIntegrationOscPs {
49
49
* Sequences pioneered by iTerm.
50
50
*/
51
51
ITerm = 1337 ,
52
- /**
53
- * Sequences by Cmder.
54
- */
55
- Cmder = 9 ,
56
- /**
57
- * Sequences by unknown terminal (maybe a command, rather than an indentifier).
58
- */
59
- Unknown7 = 7
52
+ SetCwd = 7 ,
53
+ SetWindowsFriendlyCwd = 9
60
54
}
61
55
62
56
/**
@@ -174,16 +168,6 @@ const enum ITermOscPt {
174
168
CurrentDir = 'CurrentDir'
175
169
}
176
170
177
- /**
178
- * Cmder sequences
179
- */
180
- const enum CmderOscPt {
181
- /**
182
- * Reports current working directory (CWD). `OSC 9 ; 9 ; <cwd> ST`
183
- */
184
- Code9 = '9'
185
- }
186
-
187
171
/**
188
172
* The shell integration addon extends xterm by reading shell integration sequences and creating
189
173
* capabilities and passing along relevant sequences to the capabilities. This is meant to
@@ -224,11 +208,11 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
224
208
this . capabilities . add ( TerminalCapability . PartialCommandDetection , new PartialCommandDetectionCapability ( this . _terminal ) ) ;
225
209
this . _register ( xterm . parser . registerOscHandler ( ShellIntegrationOscPs . VSCode , data => this . _handleVSCodeSequence ( data ) ) ) ;
226
210
this . _register ( xterm . parser . registerOscHandler ( ShellIntegrationOscPs . ITerm , data => this . _doHandleITermSequence ( data ) ) ) ;
227
- this . _register ( xterm . parser . registerOscHandler ( ShellIntegrationOscPs . Cmder , data => this . _doHandleCmderSequence ( data ) ) ) ;
228
211
this . _commonProtocolDisposables . push (
229
212
xterm . parser . registerOscHandler ( ShellIntegrationOscPs . FinalTerm , data => this . _handleFinalTermSequence ( data ) )
230
213
) ;
231
- this . _register ( xterm . parser . registerOscHandler ( ShellIntegrationOscPs . Unknown7 , data => this . _doHandleUnknownSequence ( ShellIntegrationOscPs . Unknown7 , data ) ) ) ;
214
+ this . _register ( xterm . parser . registerOscHandler ( ShellIntegrationOscPs . SetCwd , data => this . _doHandleSetCwd ( data ) ) ) ;
215
+ this . _register ( xterm . parser . registerOscHandler ( ShellIntegrationOscPs . SetWindowsFriendlyCwd , data => this . _doHandleSetWindowsFriendlyCwd ( data ) ) ) ;
232
216
this . _ensureCapabilitiesOrAddFailureTelemetry ( ) ;
233
217
}
234
218
@@ -417,14 +401,15 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
417
401
return false ;
418
402
}
419
403
420
- private _doHandleCmderSequence ( data : string ) : boolean {
404
+ private _doHandleSetWindowsFriendlyCwd ( data : string ) : boolean {
421
405
if ( ! this . _terminal ) {
422
406
return false ;
423
407
}
424
408
425
409
const [ command , ...args ] = data . split ( ';' ) ;
426
410
switch ( command ) {
427
- case CmderOscPt . Code9 :
411
+ case '9' :
412
+ // Encountered `OSC 9 ; 9 ; <cwd> ST`
428
413
if ( args . length ) {
429
414
this . _updateCwd ( args [ 0 ] ) ;
430
415
}
@@ -435,29 +420,20 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
435
420
return false ;
436
421
}
437
422
438
- /**
439
- * Some escape sequences are not well known/documented, so we handle them in
440
- * an ad-hoc/one-off manner. Also, note that in some cases the `ident` value
441
- * itself acts like a command (not an terminal/emulator identifier). So, it
442
- * seems logical to have a slack method that deals with such cases.
443
- */
444
- private _doHandleUnknownSequence ( ident : number , data : string ) : boolean {
423
+ private _doHandleSetCwd ( data : string ) : boolean {
445
424
if ( ! this . _terminal ) {
446
425
return false ;
447
426
}
448
427
449
428
const [ command ] = data . split ( ';' ) ;
450
- switch ( ident ) {
451
- case ShellIntegrationOscPs . Unknown7 : {
452
- // Checking for: `OSC 7 ; scheme://cwd ST`
453
- if ( command . startsWith ( 'scheme://' ) ) {
454
- // TODO: I'm not sure `scheme` here is literal or can be `file` or something else.
455
- // TODO: Possibly the path is URL-encoded, but I have no means to test it.
456
- const cwd = command . substring ( 9 ) ;
457
- this . _updateCwd ( cwd ) ;
458
- return true ;
459
- }
460
- }
429
+
430
+ // Checking for: `OSC 7 ; scheme://cwd ST`
431
+ if ( command . startsWith ( 'scheme://' ) ) {
432
+ // TODO: I'm not sure `scheme` here is literal or can be `file` or something else.
433
+ // TODO: Possibly the path is URL-encoded, but I have no means to test it.
434
+ const cwd = command . substring ( 9 ) ;
435
+ this . _updateCwd ( cwd ) ;
436
+ return true ;
461
437
}
462
438
463
439
// Unrecognized sequence
0 commit comments