@@ -7,7 +7,7 @@ import { Terminal } from 'xterm';
77import { strictEqual , deepStrictEqual , deepEqual } from 'assert' ;
88import { timeout } from 'vs/base/common/async' ;
99import * as sinon from 'sinon' ;
10- import { parseKeyValueAssignment , parseMarkSequence , ShellIntegrationAddon } from 'vs/platform/terminal/common/xterm/shellIntegrationAddon' ;
10+ import { parseKeyValueAssignment , parseMarkSequence , deserializeMessage , ShellIntegrationAddon } from 'vs/platform/terminal/common/xterm/shellIntegrationAddon' ;
1111import { ITerminalCapabilityStore , TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities' ;
1212import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock' ;
1313import { ILogService , NullLogService } from 'vs/platform/log/common/log' ;
@@ -257,6 +257,41 @@ suite('ShellIntegrationAddon', () => {
257257 } ) ;
258258} ) ;
259259
260+ suite ( 'deserializeMessage' , ( ) => {
261+ // A single literal backslash, in order to avoid confusion about whether we are escaping test data or testing escapes.
262+ const Backslash = '\\' as const ;
263+ const Newline = '\n' as const ;
264+ const Semicolon = ';' as const ;
265+
266+ type TestCase = [ title : string , input : string , expected : string ] ;
267+ const cases : TestCase [ ] = [
268+ [ 'empty' , '' , '' ] ,
269+ [ 'basic' , 'value' , 'value' ] ,
270+ [ 'space' , 'some thing' , 'some thing' ] ,
271+ [ 'escaped backslash' , `${ Backslash } ${ Backslash } ` , Backslash ] ,
272+ [ 'non-initial escaped backslash' , `foo${ Backslash } ${ Backslash } ` , `foo${ Backslash } ` ] ,
273+ [ 'two escaped backslashes' , `${ Backslash } ${ Backslash } ${ Backslash } ${ Backslash } ` , `${ Backslash } ${ Backslash } ` ] ,
274+ [ 'escaped backslash amidst text' , `Hello${ Backslash } ${ Backslash } there` , `Hello${ Backslash } there` ] ,
275+ [ 'backslash escaped literally and as hex' , `${ Backslash } ${ Backslash } is same as ${ Backslash } x5c` , `${ Backslash } is same as ${ Backslash } ` ] ,
276+ [ 'escaped semicolon' , `${ Backslash } x3b` , Semicolon ] ,
277+ [ 'non-initial escaped semicolon' , `foo${ Backslash } x3b` , `foo${ Semicolon } ` ] ,
278+ [ 'escaped semicolon (upper hex)' , `${ Backslash } x3B` , Semicolon ] ,
279+ [ 'escaped backslash followed by literal "x3b" is not a semicolon' , `${ Backslash } ${ Backslash } x3b` , `${ Backslash } x3b` ] ,
280+ [ 'non-initial escaped backslash followed by literal "x3b" is not a semicolon' , `foo${ Backslash } ${ Backslash } x3b` , `foo${ Backslash } x3b` ] ,
281+ [ 'escaped backslash followed by escaped semicolon' , `${ Backslash } ${ Backslash } ${ Backslash } x3b` , `${ Backslash } ${ Semicolon } ` ] ,
282+ [ 'escaped semicolon amidst text' , `some${ Backslash } x3bthing` , `some${ Semicolon } thing` ] ,
283+ [ 'escaped newline' , `${ Backslash } x0a` , Newline ] ,
284+ [ 'non-initial escaped newline' , `foo${ Backslash } x0a` , `foo${ Newline } ` ] ,
285+ [ 'escaped newline (upper hex)' , `${ Backslash } x0A` , Newline ] ,
286+ [ 'escaped backslash followed by literal "x0a" is not a newline' , `${ Backslash } ${ Backslash } x0a` , `${ Backslash } x0a` ] ,
287+ [ 'non-initial escaped backslash followed by literal "x0a" is not a newline' , `foo${ Backslash } ${ Backslash } x0a` , `foo${ Backslash } x0a` ] ,
288+ ] ;
289+
290+ cases . forEach ( ( [ title , input , expected ] ) => {
291+ test ( title , ( ) => strictEqual ( deserializeMessage ( input ) , expected ) ) ;
292+ } ) ;
293+ } ) ;
294+
260295test ( 'parseKeyValueAssignment' , ( ) => {
261296 type TestCase = [ title : string , input : string , expected : [ key : string , value : string | undefined ] ] ;
262297 const cases : TestCase [ ] = [
0 commit comments