Repository: microsoft/vscode (TypeScript)
Date: 2022-06-02 15:44:47+00:00
Task type: Bug Fix

Issue:
Colon after bare hyperlink is treated as its part
<!-- ⚠️⚠️ 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.67.2
- OS Version: Windows 7

Steps to Reproduce:

1. Type a bare hyperlink with a colon after it, e.g. `https://site.web/page.html: blah blah blah`
2. Notice that the colon is treated as a part of the URL.

The current way how it works may be technically correct (so you may call it a feature request rather than bug report), but is there at least one single person in the whole world who really have hyperlinks like `https://site.web/:` or `https://site.web/page:` or `https://site.web/page.html:` ? I don't think so.

Treating the last colon after a bare hyperlnk as a part of that hyperlink is not what people really expect. So maybe this should be changed? That is, if you have 

```
https://site.web/page.html: blah blah blah
```

and you click that hyperlink, you should be directed to `https://site.web/page.html` and not to `https://site.web/page.html:`


Issue discussion:

Solution patch:
diff --git a/src/vs/editor/common/languages/linkComputer.ts b/src/vs/editor/common/languages/linkComputer.ts
--- a/src/vs/editor/common/languages/linkComputer.ts
+++ b/src/vs/editor/common/languages/linkComputer.ts
@@ -160,7 +160,7 @@ function getClassifier(): CharacterClassifier<CharacterClass> {
 			_classifier.set(FORCE_TERMINATION_CHARACTERS.charCodeAt(i), CharacterClass.ForceTermination);
 		}
 
-		const CANNOT_END_WITH_CHARACTERS = '.,;';
+		const CANNOT_END_WITH_CHARACTERS = '.,;:';
 		for (let i = 0; i < CANNOT_END_WITH_CHARACTERS.length; i++) {
 			_classifier.set(CANNOT_END_WITH_CHARACTERS.charCodeAt(i), CharacterClass.CannotEndIn);
 		}


Test patch:
diff --git a/src/vs/editor/test/common/modes/linkComputer.test.ts b/src/vs/editor/test/common/modes/linkComputer.test.ts
--- a/src/vs/editor/test/common/modes/linkComputer.test.ts
+++ b/src/vs/editor/test/common/modes/linkComputer.test.ts
@@ -251,4 +251,11 @@ suite('Editor Modes - Link Computer', () => {
 			'    https://zh.wikipedia.org/wiki/“常凯申”误译事件   '
 		);
 	});
+
+	test('issue #150905: Colon after bare hyperlink is treated as its part', () => {
+		assertLink(
+			'https://site.web/page.html: blah blah blah',
+			'https://site.web/page.html                '
+		);
+	});
 });