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

Add end line + column parsing in links #78624

Closed
Vidminas opened this issue Aug 7, 2019 · 4 comments
Closed

Add end line + column parsing in links #78624

Vidminas opened this issue Aug 7, 2019 · 4 comments
Assignees
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code terminal Integrated terminal issues

Comments

@Vidminas
Copy link

Vidminas commented Aug 7, 2019

The PR #24832 added support for line and column indicators in clickable links.

Adding parsing for end line and column markers would allow clicking on a link to open a file and highlight a range, which would be very useful for using external tool tasks without having to necessarily use problem matchers.

Currently clicking on a link, such as /path/to/my/file.txt:5:56 now opens file.txt and positions the cursor at line 5, column 56.
The new feature would make clicking on links, such as /path/to/my/file.txt:5:56->5:72 open file.txt and highlight the range from line 5, column 56 to line 5, column 72.

@Tyriar
Copy link
Member

Tyriar commented Aug 7, 2019

Is this a format output by any prominent tools?

@Tyriar Tyriar added feature-request Request for new features or functionality terminal Integrated terminal issues info-needed Issue requires more information from poster labels Aug 7, 2019
@Vidminas
Copy link
Author

  1. In VS Code itself, problem matchers support parsing locations with end markers.

In vscode/src/vs/workbench/contrib/tasks/common/problemMatcher.ts the parsing is defined as:

private parseLocationInfo(value: string): Location | null {
    if (!value || !value.match(/(\d+|\d+,\d+|\d+,\d+,\d+,\d+)/)) {
	    return null;
    }
    let parts = value.split(',');
    let startLine = parseInt(parts[0]);
    let startColumn = parts.length > 1 ? parseInt(parts[1]) : undefined;
    if (parts.length > 3) {
	    return this.createLocation(startLine, startColumn, parseInt(parts[2]), parseInt(parts[3]));
    } else {
	    return this.createLocation(startLine, startColumn, undefined, undefined);
    }
}

This expects the location format to be like 5,56,5,72 or (5,56,5,72)

  1. Again, in VS Code itself, the Range type provides a toString() implementation, in vscode/src/vs/editor/common/core/range.ts as:
/**
 * Transform to a user presentable string representation.
 */
public toString(): string {
	return '[' + this.startLineNumber + ',' + this.startColumn + ' -> ' + this.endLineNumber + ',' + this.endColumn + ']';
}

This is the format [5,56->5,72] and is what I based my tool's output on, with the modification of ommiting square brackets and using colons instead of commas.

  1. Finally, again within VS Code, the terminal window link handler currently does not support end markers, but it does support start markers in a multitude of formats. Defined in vscode/src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts as:
const lineAndColumnClause = [
	'((\\S*)", line ((\\d+)( column (\\d+))?))', // "(file path)", line 45 [see #40468]
	'((\\S*)",((\\d+)(:(\\d+))?))', // "(file path)",45 [see #78205]
	'((\\S*) on line ((\\d+)(, column (\\d+))?))', // (file path) on line 8, column 13
	'((\\S*):line ((\\d+)(, column (\\d+))?))', // (file path):line 8, column 13
	'(([^\\s\\(\\)]*)(\\s?[\\(\\[](\\d+)(,\\s?(\\d+))?)[\\)\\]])', // (file path)(45), (file path) (45), (file path)(45,18), (file path) (45,18), (file path)(45, 18), (file path) (45, 18), also with []
	'(([^:\\s\\(\\)<>\'\"\\[\\]]*)(:(\\d+))?(:(\\d+))?)' // (file path):336, (file path):336:9
].join('|').replace(/ /g, `[${'\u00A0'} ]`);

So to summarise, I think that at the very least the formats 1, 2, 3, 4, (1, 2, 3, 4), [1,2 -> 3,4] should be supported.

But it would also make sense to support formats like 1:2:3:4, 1:2->3:4, [1:2->3:4], 1,2->3,4, lines 5->12, line 5, column 8 to line 5 column 22 to properly match existing functionality with start markers (this list is not exhaustive and how the "wordy" output formats should be phrased is also up for discussion).

@Tyriar Tyriar removed the info-needed Issue requires more information from poster label Aug 12, 2019
@Tyriar
Copy link
Member

Tyriar commented Oct 9, 2019

Closing as out of scope as the terminal is focused on CLI tools which do not generally use this format. FYI @alexr00

@Tyriar Tyriar added the *out-of-scope Posted issue is not in scope of VS Code label Oct 9, 2019
@vscodebot
Copy link

vscodebot bot commented Oct 9, 2019

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

@vscodebot vscodebot bot closed this as completed Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code terminal Integrated terminal issues
Projects
None yet
Development

No branches or pull requests

2 participants