Exclude pipe char from suffix link paths

Fixes #176756
This commit is contained in:
Daniel Imms
2023-03-14 06:22:03 -07:00
parent 384b03f263
commit cc14facda8
2 changed files with 40 additions and 1 deletions
@@ -205,7 +205,7 @@ export function toLinkSuffix(match: RegExpExecArray | null): ILinkSuffix | null
}
// Paths cannot start with opening brackets
const linkWithSuffixPathCharacters = /(?<path>[^\s\[\({][^\s]*)$/;
const linkWithSuffixPathCharacters = /(?<path>[^\s\|\[\({][^\s\|]*)$/;
export function detectLinks(line: string, os: OperatingSystem) {
// 1: Detect all links on line via suffixes first
@@ -329,6 +329,45 @@ suite('TerminalLinkParsing', () => {
);
});
test('should exclude pipe characters from link paths', () => {
deepStrictEqual(
detectLinks('|C:\\Github\\microsoft\\vscode|', OperatingSystem.Windows),
[
{
path: {
index: 1,
text: 'C:\\Github\\microsoft\\vscode'
},
prefix: undefined,
suffix: undefined
}
] as IParsedLink[]
);
});
test('should exclude pipe characters from link paths with suffixes', () => {
deepStrictEqual(
detectLinks('|C:\\Github\\microsoft\\vscode:400|', OperatingSystem.Windows),
[
{
path: {
index: 1,
text: 'C:\\Github\\microsoft\\vscode'
},
prefix: undefined,
suffix: {
col: undefined,
row: 400,
suffix: {
index: 27,
text: ':400'
}
}
}
] as IParsedLink[]
);
});
suite('should detect file names in git diffs', () => {
test('--- a/foo/bar', () => {
deepStrictEqual(