Skip to content

Commit

Permalink
Add support for links 'foo(l:c)' and 'foo (l:c)'
Browse files Browse the repository at this point in the history
Fixes #229842
  • Loading branch information
Tyriar committed Sep 28, 2024
1 parent 626fc7d commit 4d7a7a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -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' },
Expand Down

0 comments on commit 4d7a7a4

Please sign in to comment.