Skip to content

Commit 90f0439

Browse files
authored
Merge pull request microsoft#29212 from Krzysztof-Cieslak/terminal_link_handler_square
Add Support [line, col] in terminal links
2 parents a057a59 + 3696e74 commit 90f0439

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ replacing space with nonBreakningSpace or space ASCII code - 32. */
3535
const lineAndColumnClause = [
3636
'((\\S*) on line ((\\d+)(, column (\\d+))?))', // (file path) on line 8, column 13
3737
'((\\S*):line ((\\d+)(, column (\\d+))?))', // (file path):line 8, column 13
38-
'(([^\\s\\(\\)]*)(\\s?\\((\\d+)(,(\\d+))?)\\))', // (file path)(45), (file path) (45), (file path)(45,18), (file path) (45,18)
38+
'(([^\\s\\(\\)]*)(\\s?[\\(\\[](\\d+)(,(\\d+))?)[\\)\\]])', // (file path)(45), (file path) (45), (file path)(45,18), (file path) (45,18)
3939
'(([^:\\s\\(\\)<>\'\"\\[\\]]*)(:(\\d+))?(:(\\d+))?)' // (file path):336, (file path):336:9
4040
].join('|').replace(/ /g, `[${'\u00A0'} ]`);
4141

@@ -71,7 +71,6 @@ export class TerminalLinkHandler {
7171
const baseLocalLinkClause = _platform === platform.Platform.Windows ? winLocalLinkClause : unixLocalLinkClause;
7272
// Append line and column number regex
7373
this._localLinkPattern = new RegExp(`${baseLocalLinkClause}(${lineAndColumnClause})`);
74-
7574
this._xterm.setHypertextLinkHandler(this._wrapLinkHandler(() => true));
7675
this._xterm.setHypertextValidationCallback((uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => {
7776
this._validateWebLink(uri, element, callback);

src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ suite('Workbench - TerminalLinkHandler', () => {
9797
{ urlFormat: '{0}({1},{2})', line: '5', column: '3' },
9898
{ urlFormat: '{0} ({1},{2})', line: '5', column: '3' },
9999
{ urlFormat: '{0}:{1}', line: '5' },
100-
{ urlFormat: '{0}:{1}:{2}', line: '5', column: '3' }
100+
{ urlFormat: '{0}:{1}:{2}', line: '5', column: '3' },
101+
{ urlFormat: '{0}[{1}]', line: '5' },
102+
{ urlFormat: '{0} [{1}]', line: '5' },
103+
{ urlFormat: '{0}[{1},{2}]', line: '5', column: '3' },
104+
{ urlFormat: '{0} [{1},{2}]', line: '5', column: '3' }
101105
];
102106

103107
linkUrls.forEach(linkUrl => {
@@ -154,7 +158,11 @@ suite('Workbench - TerminalLinkHandler', () => {
154158
{ urlFormat: '{0}({1},{2})', line: '5', column: '3' },
155159
{ urlFormat: '{0} ({1},{2})', line: '5', column: '3' },
156160
{ urlFormat: '{0}:{1}', line: '5' },
157-
{ urlFormat: '{0}:{1}:{2}', line: '5', column: '3' }
161+
{ urlFormat: '{0}:{1}:{2}', line: '5', column: '3' },
162+
{ urlFormat: '{0}[{1}]', line: '5' },
163+
{ urlFormat: '{0} [{1}]', line: '5' },
164+
{ urlFormat: '{0}[{1},{2}]', line: '5', column: '3' },
165+
{ urlFormat: '{0} [{1},{2}]', line: '5', column: '3' }
158166
];
159167

160168
linkUrls.forEach(linkUrl => {

0 commit comments

Comments
 (0)