Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opening links in the terminal with column numbers #210898

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,17 @@ export class TerminalSearchLinkOpener implements ITerminalLinkOpener {
// Try extract any trailing line and column numbers by matching the text against parsed
// links. This will give a search link `foo` on a line like `"foo", line 10` to open the
// quick pick with `foo:10` as the contents.
//
// This also normalizes the path to remove suffixes like :10 or :5.0-4
if (link.contextLine) {
const parsedLinks = detectLinks(link.contextLine, this._getOS());
const matchingParsedLink = parsedLinks.find(parsedLink => parsedLink.suffix && link.text === parsedLink.path.text);
// Optimistically check that the link _starts with_ the parsed link text. If so,
// continue to use the parsed link
const matchingParsedLink = parsedLinks.find(parsedLink => parsedLink.suffix && link.text.startsWith(parsedLink.path.text));
if (matchingParsedLink) {
if (matchingParsedLink.suffix?.row !== undefined) {
// Normalize the path based on the parsed link
text = matchingParsedLink.path.text;
text += `:${matchingParsedLink.suffix.row}`;
if (matchingParsedLink.suffix?.col !== undefined) {
text += `:${matchingParsedLink.suffix.col}`;
Expand Down
Loading