Repository: microsoft/vscode (TypeScript)
Date: 2023-03-14 13:23:27+00:00
Task type: Bug Fix

Issue:
v1.76.x - terminal ctrl-click code-line lookup regexp fails
<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 1.76.1
- OS Version: windows 11


This worked before the 1.76.0 upgrade, I've also tested starting with `code --disable-extensions`

Steps to Reproduce:

1. get output in terminal like:
`20230310122934.069|ERROR|C:\dist\work\multitenant-fullstack-test\tools\scim.py:495|user with username:15918896373 not found`

2. .ctrl+click and it fails miserably because the regex to fetch the url seem to be corrupt:
it matches 'C:\dist\work\multitenant-fullstack-test\tools\scim.py:495|user'
![vscode-linelookup-regexp-fails](https://user-images.githubusercontent.com/11349883/224307740-f7636a62-8c99-4c5e-a843-f0d7eb974dcc.jpg)

 This works:
 20230310124108.071|INFO|C:\dist\work\multitenant-fullstack-test\tests\test_03_scim_username.py:40|user from mock:{
![vscode-linelookup-regexp-works](https://user-images.githubusercontent.com/11349883/224308835-e41c5f85-971f-4f96-9e7a-7c2c7faec932.jpg)




Issue discussion:
This actually works fine for me when there's no line number:

![image](https://user-images.githubusercontent.com/2193314/225011154-04baae4d-9ccf-4134-b3cc-61944e1beaef.png)


Solution patch:
diff --git a/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts
--- a/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts
+++ b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts
@@ -451,7 +451,7 @@ const terminalConfiguration: IConfigurationNode = {
 			description: localize('terminal.integrated.wordSeparators', "A string containing all characters to be considered word separators by the double-click to select word feature."),
 			type: 'string',
 			// allow-any-unicode-next-line
-			default: ' ()[]{}\',"`─‘’'
+			default: ' ()[]{}\',"`─‘’|'
 		},
 		[TerminalSettingId.EnableFileLinks]: {
 			description: localize('terminal.integrated.enableFileLinks', "Whether to enable file links in terminals. Links can be slow when working on a network drive in particular because each file link is verified against the file system. Changing this will take effect only in new terminals."),
diff --git a/src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts b/src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts
--- a/src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts
+++ b/src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts
@@ -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


Test patch:
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
--- a/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts
+++ b/src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts
@@ -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(