From 4d7a7a45e3ca33c2e10b2f95342f9746c6258969 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 28 Sep 2024 06:54:31 -0700 Subject: [PATCH] Add support for links 'foo(l:c)' and 'foo (l:c)' Fixes #229842 --- .../links/browser/terminalLinkParsing.ts | 11 ++++++++--- .../links/test/browser/terminalLinkParsing.test.ts | 4 ++++ .../test/browser/terminalLocalLinkDetector.test.ts | 4 ++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts b/src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts index 7f148d7fecf15..4ff47d600d311 100644 --- a/src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts +++ b/src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts @@ -109,14 +109,19 @@ function generateLinkSuffixRegex(eolOnly: boolean) { // "foo", lines 339-341 [#171880] // "foo", lines 339-341, characters 12-789 [#178287] `['"]?(?:,? |: ?| on )lines? ${r()}(?:-${re()})?(?:,? (?:col(?:umn)?|characters?) ${c()}(?:-${ce()})?)?` + eolSuffix, + // () and [] are interchangeable // foo(339) // foo(339,12) // foo(339, 12) // foo (339) - // ... + // foo (339,12) + // foo (339, 12) // foo: (339) - // ... - `:? ?[\\[\\(]${r()}(?:, ?${c()})?[\\]\\)]` + eolSuffix, + // foo: (339,12) + // foo: (339, 12) + // foo(339:12) [#229842] + // foo (339:12) [#229842] + `:? ?[\\[\\(]${r()}(?:(?:, ?|:)${c()})?[\\]\\)]` + eolSuffix, ]; const suffixClause = lineAndColumnRegexClauses diff --git a/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts b/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts index 3f61393ab7110..099e639ee820e 100644 --- a/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts +++ b/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts @@ -125,6 +125,8 @@ const testLinks: ITestLink[] = [ { link: 'foo: (339)', prefix: undefined, suffix: ': (339)', hasRow: true, hasCol: false }, { link: 'foo: (339,12)', prefix: undefined, suffix: ': (339,12)', hasRow: true, hasCol: true }, { link: 'foo: (339, 12)', prefix: undefined, suffix: ': (339, 12)', hasRow: true, hasCol: true }, + { link: 'foo(339:12)', prefix: undefined, suffix: '(339:12)', hasRow: true, hasCol: true }, + { link: 'foo (339:12)', prefix: undefined, suffix: ' (339:12)', hasRow: true, hasCol: true }, // Square brackets { link: 'foo[339]', prefix: undefined, suffix: '[339]', hasRow: true, hasCol: false }, @@ -136,6 +138,8 @@ const testLinks: ITestLink[] = [ { link: 'foo: [339]', prefix: undefined, suffix: ': [339]', hasRow: true, hasCol: false }, { link: 'foo: [339,12]', prefix: undefined, suffix: ': [339,12]', hasRow: true, hasCol: true }, { link: 'foo: [339, 12]', prefix: undefined, suffix: ': [339, 12]', hasRow: true, hasCol: true }, + { link: 'foo[339:12]', prefix: undefined, suffix: '[339:12]', hasRow: true, hasCol: true }, + { link: 'foo [339:12]', prefix: undefined, suffix: ' [339:12]', hasRow: true, hasCol: true }, // OCaml-style { link: '"foo", line 339, character 12', prefix: '"', suffix: '", line 339, character 12', hasRow: true, hasCol: true }, diff --git a/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLocalLinkDetector.test.ts b/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLocalLinkDetector.test.ts index 70d503f1526ef..df3d642769a3e 100644 --- a/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLocalLinkDetector.test.ts +++ b/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLocalLinkDetector.test.ts @@ -110,6 +110,8 @@ const supportedLinkFormats: LinkFormatInfo[] = [ { urlFormat: '{0}({1}, {2})', line: '5', column: '3' }, { urlFormat: '{0} ({1}, {2})', line: '5', column: '3' }, { urlFormat: '{0}: ({1}, {2})', line: '5', column: '3' }, + { urlFormat: '{0}({1}:{2})', line: '5', column: '3' }, + { urlFormat: '{0} ({1}:{2})', line: '5', column: '3' }, { urlFormat: '{0}:{1}', line: '5' }, { urlFormat: '{0}:{1}:{2}', line: '5', column: '3' }, { urlFormat: '{0} {1}:{2}', line: '5', column: '3' }, @@ -121,6 +123,8 @@ const supportedLinkFormats: LinkFormatInfo[] = [ { urlFormat: '{0}[{1}, {2}]', line: '5', column: '3' }, { urlFormat: '{0} [{1}, {2}]', line: '5', column: '3' }, { urlFormat: '{0}: [{1}, {2}]', line: '5', column: '3' }, + { urlFormat: '{0}[{1}:{2}]', line: '5', column: '3' }, + { urlFormat: '{0} [{1}:{2}]', line: '5', column: '3' }, { urlFormat: '{0}",{1}', line: '5' }, { urlFormat: '{0}\',{1}', line: '5' }, { urlFormat: '{0}#{1}', line: '5' },