diff --git a/src/vs/editor/common/modes/linkComputer.ts b/src/vs/editor/common/modes/linkComputer.ts index da76e1dc8ae59f723432935353ff5906c8f20720..ad801ef2e976de173738de8e0030efdeeb9a40dc 100644 --- a/src/vs/editor/common/modes/linkComputer.ts +++ b/src/vs/editor/common/modes/linkComputer.ts @@ -205,7 +205,7 @@ class LinkComputer { let resetStateMachine = false; const chCode = line.charCodeAt(j); - if (state === State.Accept || state === State.End) { + if (state === State.Accept) { let chClass: CharacterClass; switch (chCode) { case CharCode.OpenParen: @@ -245,9 +245,22 @@ class LinkComputer { // Check if character terminates link if (chClass === CharacterClass.ForceTermination) { - if (state === State.Accept) { - result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, j)); - } + result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, j)); + resetStateMachine = true; + } + } else if (state === State.End) { + + let chClass: CharacterClass; + if (chCode === CharCode.OpenSquareBracket) { + // Allow for the authority part to contain ipv6 addresses which contain [ and ] + hasOpenSquareBracket = true; + chClass = CharacterClass.None; + } else { + chClass = classifier.get(chCode); + } + + // Check if character terminates link + if (chClass === CharacterClass.ForceTermination) { resetStateMachine = true; } else { state = State.Accept; diff --git a/src/vs/editor/test/common/modes/linkComputer.test.ts b/src/vs/editor/test/common/modes/linkComputer.test.ts index 70daaefe1d318683d77fbc586ad97777c2399d0c..b4f3b76f688d57c05265b0a0b5cc79fc32313f59 100644 --- a/src/vs/editor/test/common/modes/linkComputer.test.ts +++ b/src/vs/editor/test/common/modes/linkComputer.test.ts @@ -195,4 +195,11 @@ suite('Editor Modes - Link Computer', () => { ' https://msdn.microsoft.com/en-us/library/windows/desktop/ms687414(v=vs.85).aspx ' ); }); + + test('issue #62278: "Ctrl + click to follow link" for IPv6 URLs', () => { + assertLink( + 'let x = "http://[::1]:5000/connect/token"', + ' http://[::1]:5000/connect/token ' + ); + }); });