Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for links 'foo(l:c)' and 'foo (l:c)' #230043

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading