Skip to content

Commit 6afd37f

Browse files
committed
Correct buffer range of multi-line links
1 parent c3e6d72 commit 6afd37f

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/vs/workbench/contrib/terminalContrib/links/browser/links.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,16 @@ export interface ITerminalSimpleLink {
8383
*/
8484
uri?: URI;
8585

86-
// TODO: This is similar to parsedLink, combine into a single prop?
8786
/**
8887
* The location or selection range of the link.
8988
*/
9089
selection?: ITextEditorSelection;
9190

91+
/**
92+
* Whether to trim a trailing colon at the end of a path.
93+
*/
94+
disableTrimColon?: boolean;
95+
9296
/**
9397
* A hover label to override the default for the type.
9498
*/

src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkDetectorAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class TerminalLinkDetectorAdapter extends Disposable implements ILinkProv
103103

104104
private _createTerminalLink(l: ITerminalSimpleLink, activateCallback: XtermLinkMatcherHandler): TerminalLink {
105105
// Remove trailing colon if there is one so the link is more useful
106-
if (l.text.length > 0 && l.text.charAt(l.text.length - 1) === ':') {
106+
if (!l.disableTrimColon && l.text.length > 0 && l.text.charAt(l.text.length - 1) === ':') {
107107
l.text = l.text.slice(0, -1);
108108
l.bufferRange.end.x--;
109109
}

src/vs/workbench/contrib/terminalContrib/links/browser/terminalMultiLineLinkDetector.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ const enum Constants {
1818
*/
1919
MaxLineLength = 2000,
2020

21-
/**
22-
* The maximum number of links in a line to resolve against the file system. This limit is put
23-
* in place to avoid sending excessive data when remote connections are in place.
24-
*/
25-
MaxResolvedLinksInLine = 10,
26-
2721
/**
2822
* The maximum length of a link to resolve against the file system. This limit is put in place
2923
* to avoid sending excessive data when remote connections are in place.
@@ -68,7 +62,6 @@ export class TerminalMultiLineLinkDetector implements ITerminalLinkDetector {
6862
return [];
6963
}
7064

71-
let stringIndex = -1;
7265

7366
this._logService.trace('terminalMultiLineLinkDetector#detect text', text);
7467

@@ -92,7 +85,6 @@ export class TerminalMultiLineLinkDetector implements ITerminalLinkDetector {
9285
continue;
9386
}
9487

95-
// TODO: Log more info?
9688
this._logService.trace('terminalMultiLineLinkDetector#detect candidates', link);
9789

9890
// Scan up looking for the first line that could be a path
@@ -124,11 +116,10 @@ export class TerminalMultiLineLinkDetector implements ITerminalLinkDetector {
124116
}
125117

126118
// Convert the entire line's text string index into a wrapped buffer range
127-
stringIndex = text.indexOf(link);
128119
const bufferRange = convertLinkRangeToBuffer(lines, this.xterm.cols, {
129-
startColumn: stringIndex + 1,
120+
startColumn: 1,
130121
startLineNumber: 1,
131-
endColumn: stringIndex + 1 + text.length + 1,
122+
endColumn: 1 + text.length,
132123
endLineNumber: 1
133124
}, startLine);
134125

@@ -139,6 +130,7 @@ export class TerminalMultiLineLinkDetector implements ITerminalLinkDetector {
139130
startLineNumber: parseInt(line),
140131
startColumn: col ? parseInt(col) : 0
141132
},
133+
disableTrimColon: true,
142134
bufferRange: bufferRange,
143135
type
144136
};

0 commit comments

Comments
 (0)