From 0d3af038ff653a44fdf1b9dc69a6477062c3dea9 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 5 Jan 2023 09:20:20 -0800 Subject: [PATCH 1/2] Add unit tests for parsing [] and ' --- .../browser/links/terminalLinkParsing.test.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkParsing.test.ts b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkParsing.test.ts index 9316c6d49f708..787070346ceea 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkParsing.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkParsing.test.ts @@ -21,6 +21,7 @@ const testLinks: ITestLink[] = [ { link: 'foo:339:12', suffix: ':339:12', hasRow: true, hasCol: true }, { link: 'foo 339', suffix: ' 339', hasRow: true, hasCol: false }, { link: 'foo 339:12', suffix: ' 339:12', hasRow: true, hasCol: true }, + { link: '"foo",339', suffix: '",339', hasRow: true, hasCol: false }, { link: '"foo",339:12', suffix: '",339:12', hasRow: true, hasCol: true }, { link: '"foo", line 339', suffix: '", line 339', hasRow: true, hasCol: false }, @@ -35,15 +36,38 @@ const testLinks: ITestLink[] = [ { link: '"foo" on line 339', suffix: '" on line 339', hasRow: true, hasCol: false }, { link: '"foo" on line 339, col 12', suffix: '" on line 339, col 12', hasRow: true, hasCol: true }, { link: '"foo" on line 339, column 12', suffix: '" on line 339, column 12', hasRow: true, hasCol: true }, + + { link: '\'foo\',339', suffix: '\',339', hasRow: true, hasCol: false }, + { link: '\'foo\',339:12', suffix: '\',339:12', hasRow: true, hasCol: true }, + { link: '\'foo\', line 339', suffix: '\', line 339', hasRow: true, hasCol: false }, + { link: '\'foo\', line 339, col 12', suffix: '\', line 339, col 12', hasRow: true, hasCol: true }, + { link: '\'foo\', line 339, column 12', suffix: '\', line 339, column 12', hasRow: true, hasCol: true }, + { link: '\'foo\':line 339', suffix: '\':line 339', hasRow: true, hasCol: false }, + { link: '\'foo\':line 339, col 12', suffix: '\':line 339, col 12', hasRow: true, hasCol: true }, + { link: '\'foo\':line 339, column 12', suffix: '\':line 339, column 12', hasRow: true, hasCol: true }, + { link: '\'foo\': line 339', suffix: '\': line 339', hasRow: true, hasCol: false }, + { link: '\'foo\': line 339, col 12', suffix: '\': line 339, col 12', hasRow: true, hasCol: true }, + { link: '\'foo\': line 339, column 12', suffix: '\': line 339, column 12', hasRow: true, hasCol: true }, + { link: '\'foo\' on line 339', suffix: '\' on line 339', hasRow: true, hasCol: false }, + { link: '\'foo\' on line 339, col 12', suffix: '\' on line 339, col 12', hasRow: true, hasCol: true }, + { link: '\'foo\' on line 339, column 12', suffix: '\' on line 339, column 12', hasRow: true, hasCol: true }, + { link: 'foo(339)', suffix: '(339)', hasRow: true, hasCol: false }, { link: 'foo(339,12)', suffix: '(339,12)', hasRow: true, hasCol: true }, { link: 'foo(339, 12)', suffix: '(339, 12)', hasRow: true, hasCol: true }, { link: 'foo (339)', suffix: ' (339)', hasRow: true, hasCol: false }, { link: 'foo (339,12)', suffix: ' (339,12)', hasRow: true, hasCol: true }, { link: 'foo (339, 12)', suffix: ' (339, 12)', hasRow: true, hasCol: true }, + + { link: 'foo[339]', suffix: '[339]', hasRow: true, hasCol: false }, + { link: 'foo[339,12]', suffix: '[339,12]', hasRow: true, hasCol: true }, + { link: 'foo[339, 12]', suffix: '[339, 12]', hasRow: true, hasCol: true }, + { link: 'foo [339]', suffix: ' [339]', hasRow: true, hasCol: false }, + { link: 'foo [339,12]', suffix: ' [339,12]', hasRow: true, hasCol: true }, + { link: 'foo [339, 12]', suffix: ' [339, 12]', hasRow: true, hasCol: true }, ]; -suite('TerminalLinkParsing', () => { +suite.only('TerminalLinkParsing', () => { suite('removeLinkSuffix', () => { for (const testLink of testLinks) { test('`' + testLink.link + '`', () => { From bff0b5a2b2357acce9668d4fb91111a48ce0b6d6 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 5 Jan 2023 09:23:52 -0800 Subject: [PATCH 2/2] Add unit tests for nbsp in links --- .../browser/links/terminalLinkParsing.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkParsing.test.ts b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkParsing.test.ts index 787070346ceea..a0c7194691232 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkParsing.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkParsing.test.ts @@ -16,12 +16,14 @@ interface ITestLink { const testRow = 339; const testCol = 12; const testLinks: ITestLink[] = [ + // Simple { link: 'foo', suffix: undefined, hasRow: false, hasCol: false }, { link: 'foo:339', suffix: ':339', hasRow: true, hasCol: false }, { link: 'foo:339:12', suffix: ':339:12', hasRow: true, hasCol: true }, { link: 'foo 339', suffix: ' 339', hasRow: true, hasCol: false }, { link: 'foo 339:12', suffix: ' 339:12', hasRow: true, hasCol: true }, + // Double quotes { link: '"foo",339', suffix: '",339', hasRow: true, hasCol: false }, { link: '"foo",339:12', suffix: '",339:12', hasRow: true, hasCol: true }, { link: '"foo", line 339', suffix: '", line 339', hasRow: true, hasCol: false }, @@ -37,6 +39,7 @@ const testLinks: ITestLink[] = [ { link: '"foo" on line 339, col 12', suffix: '" on line 339, col 12', hasRow: true, hasCol: true }, { link: '"foo" on line 339, column 12', suffix: '" on line 339, column 12', hasRow: true, hasCol: true }, + // Single quotes { link: '\'foo\',339', suffix: '\',339', hasRow: true, hasCol: false }, { link: '\'foo\',339:12', suffix: '\',339:12', hasRow: true, hasCol: true }, { link: '\'foo\', line 339', suffix: '\', line 339', hasRow: true, hasCol: false }, @@ -52,6 +55,7 @@ const testLinks: ITestLink[] = [ { link: '\'foo\' on line 339, col 12', suffix: '\' on line 339, col 12', hasRow: true, hasCol: true }, { link: '\'foo\' on line 339, column 12', suffix: '\' on line 339, column 12', hasRow: true, hasCol: true }, + // Parentheses { link: 'foo(339)', suffix: '(339)', hasRow: true, hasCol: false }, { link: 'foo(339,12)', suffix: '(339,12)', hasRow: true, hasCol: true }, { link: 'foo(339, 12)', suffix: '(339, 12)', hasRow: true, hasCol: true }, @@ -59,15 +63,24 @@ const testLinks: ITestLink[] = [ { link: 'foo (339,12)', suffix: ' (339,12)', hasRow: true, hasCol: true }, { link: 'foo (339, 12)', suffix: ' (339, 12)', hasRow: true, hasCol: true }, + // Square brackets { link: 'foo[339]', suffix: '[339]', hasRow: true, hasCol: false }, { link: 'foo[339,12]', suffix: '[339,12]', hasRow: true, hasCol: true }, { link: 'foo[339, 12]', suffix: '[339, 12]', hasRow: true, hasCol: true }, { link: 'foo [339]', suffix: ' [339]', hasRow: true, hasCol: false }, { link: 'foo [339,12]', suffix: ' [339,12]', hasRow: true, hasCol: true }, { link: 'foo [339, 12]', suffix: ' [339, 12]', hasRow: true, hasCol: true }, + + // Non-breaking space + { link: 'foo\u00A0339:12', suffix: '\u00A0339:12', hasRow: true, hasCol: true }, + { link: '"foo" on line 339,\u00A0column 12', suffix: '" on line 339,\u00A0column 12', hasRow: true, hasCol: true }, + { link: '\'foo\' on line\u00A0339, column 12', suffix: '\' on line\u00A0339, column 12', hasRow: true, hasCol: true }, + { link: 'foo (339,\u00A012)', suffix: ' (339,\u00A012)', hasRow: true, hasCol: true }, + { link: 'foo\u00A0[339, 12]', suffix: '\u00A0[339, 12]', hasRow: true, hasCol: true }, + ]; -suite.only('TerminalLinkParsing', () => { +suite('TerminalLinkParsing', () => { suite('removeLinkSuffix', () => { for (const testLink of testLinks) { test('`' + testLink.link + '`', () => {