Correct buffer range of multi-line links

This commit is contained in:
Daniel Imms 2023-06-22 17:21:45 -07:00
parent c3e6d72284
commit 6afd37fd57
No known key found for this signature in database
GPG key ID: E5CF412B63651C69
3 changed files with 9 additions and 13 deletions

View file

@ -83,12 +83,16 @@ export interface ITerminalSimpleLink {
*/
uri?: URI;
// TODO: This is similar to parsedLink, combine into a single prop?
/**
* The location or selection range of the link.
*/
selection?: ITextEditorSelection;
/**
* Whether to trim a trailing colon at the end of a path.
*/
disableTrimColon?: boolean;
/**
* A hover label to override the default for the type.
*/

View file

@ -103,7 +103,7 @@ export class TerminalLinkDetectorAdapter extends Disposable implements ILinkProv
private _createTerminalLink(l: ITerminalSimpleLink, activateCallback: XtermLinkMatcherHandler): TerminalLink {
// Remove trailing colon if there is one so the link is more useful
if (l.text.length > 0 && l.text.charAt(l.text.length - 1) === ':') {
if (!l.disableTrimColon && l.text.length > 0 && l.text.charAt(l.text.length - 1) === ':') {
l.text = l.text.slice(0, -1);
l.bufferRange.end.x--;
}

View file

@ -18,12 +18,6 @@ const enum Constants {
*/
MaxLineLength = 2000,
/**
* The maximum number of links in a line to resolve against the file system. This limit is put
* in place to avoid sending excessive data when remote connections are in place.
*/
MaxResolvedLinksInLine = 10,
/**
* The maximum length of a link to resolve against the file system. This limit is put in place
* to avoid sending excessive data when remote connections are in place.
@ -68,7 +62,6 @@ export class TerminalMultiLineLinkDetector implements ITerminalLinkDetector {
return [];
}
let stringIndex = -1;
this._logService.trace('terminalMultiLineLinkDetector#detect text', text);
@ -92,7 +85,6 @@ export class TerminalMultiLineLinkDetector implements ITerminalLinkDetector {
continue;
}
// TODO: Log more info?
this._logService.trace('terminalMultiLineLinkDetector#detect candidates', link);
// Scan up looking for the first line that could be a path
@ -124,11 +116,10 @@ export class TerminalMultiLineLinkDetector implements ITerminalLinkDetector {
}
// Convert the entire line's text string index into a wrapped buffer range
stringIndex = text.indexOf(link);
const bufferRange = convertLinkRangeToBuffer(lines, this.xterm.cols, {
startColumn: stringIndex + 1,
startColumn: 1,
startLineNumber: 1,
endColumn: stringIndex + 1 + text.length + 1,
endColumn: 1 + text.length,
endLineNumber: 1
}, startLine);
@ -139,6 +130,7 @@ export class TerminalMultiLineLinkDetector implements ITerminalLinkDetector {
startLineNumber: parseInt(line),
startColumn: col ? parseInt(col) : 0
},
disableTrimColon: true,
bufferRange: bufferRange,
type
};