@@ -317,7 +317,7 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
317
317
case VSCodeOscPt . CommandLine : {
318
318
let commandLine : string ;
319
319
if ( args . length === 1 ) {
320
- commandLine = this . _deserializeMessage ( args [ 0 ] ) ;
320
+ commandLine = deserializeMessage ( args [ 0 ] ) ;
321
321
} else {
322
322
commandLine = '' ;
323
323
}
@@ -341,7 +341,7 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
341
341
return true ;
342
342
}
343
343
case VSCodeOscPt . Property : {
344
- const { key, value } = this . _parseKeyValueAssignment ( args [ 0 ] ) ;
344
+ const { key, value } = parseKeyValueAssignment ( args [ 0 ] ) ;
345
345
if ( value === undefined ) {
346
346
return true ;
347
347
}
@@ -383,7 +383,7 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
383
383
}
384
384
default : {
385
385
// Checking for known `<key>=<value>` pairs.
386
- const { key, value } = this . _parseKeyValueAssignment ( command ) ;
386
+ const { key, value } = parseKeyValueAssignment ( command ) ;
387
387
388
388
if ( value === undefined ) {
389
389
// No '=' was found, so it's not a property assignment.
@@ -481,28 +481,29 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
481
481
}
482
482
return commandDetection ;
483
483
}
484
+ }
484
485
485
- private _deserializeMessage ( message : string ) : string {
486
- let result = message . replace ( / \\ \\ / g, '\\' ) ;
487
- const deserializeRegex = / \\ x ( [ 0 - 9 a - f ] { 2 } ) / i;
488
- while ( true ) {
489
- const match = result . match ( deserializeRegex ) ;
490
- if ( ! match ?. index || match . length < 2 ) {
491
- break ;
492
- }
493
- result = result . slice ( 0 , match . index ) + String . fromCharCode ( parseInt ( match [ 1 ] , 16 ) ) + result . slice ( match . index + 4 ) ;
486
+ export function deserializeMessage ( message : string ) : string {
487
+ let result = message . replace ( / \\ \\ / g, '\\' ) ;
488
+ const deserializeRegex = / \\ x ( [ 0 - 9 a - f ] { 2 } ) / i;
489
+ while ( true ) {
490
+ const match = result . match ( deserializeRegex ) ;
491
+ if ( ! match ?. index || match . length < 2 ) {
492
+ break ;
494
493
}
495
- return result ;
494
+ result = result . slice ( 0 , match . index ) + String . fromCharCode ( parseInt ( match [ 1 ] , 16 ) ) + result . slice ( match . index + 4 ) ;
496
495
}
496
+ return result ;
497
+ }
497
498
498
- private _parseKeyValueAssignment ( message : string ) : { key : string ; value : string | undefined } {
499
- const [ key , ...rawValues ] = message . split ( '=' ) ;
500
- if ( ! rawValues . length ) {
501
- return { key, value : undefined } ; // No '=' was found.
502
- }
503
- const rawValue = rawValues . join ( '=' ) ;
504
- const value = this . _deserializeMessage ( rawValue ) ;
505
- return { key, value } ;
499
+ export function parseKeyValueAssignment ( message : string ) : { key : string ; value : string | undefined } {
500
+ const deserialized = deserializeMessage ( message ) ;
501
+ const separatorIndex = deserialized . indexOf ( '=' ) ;
502
+ if ( separatorIndex === - 1 ) {
503
+ return { key : deserialized , value : undefined } ; // No '=' was found.
506
504
}
505
+ return {
506
+ key : deserialized . substring ( 0 , separatorIndex ) ,
507
+ value : deserialized . substring ( 1 + separatorIndex )
508
+ } ;
507
509
}
508
-
0 commit comments