Skip to content

Commit b7237d8

Browse files
authored
💄 Include file system path in debug mode's URI/link hovers (microsoft#165709)
* 💄 Include file system path in debug mode's URI/link hovers Signed-off-by: Babak K. Shandiz <[email protected]> * 💄 Include full text in debug mode's link hovers Signed-off-by: Babak K. Shandiz <[email protected]> * 🔨 Make showing link fulltext as an optional parameter Signed-off-by: Babak K. Shandiz <[email protected]> * 🖼 Enable showing fulltext of links for debug view expressions Signed-off-by: Babak K. Shandiz <[email protected]> Signed-off-by: Babak K. Shandiz <[email protected]>
1 parent a2aa91d commit b7237d8

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/vs/workbench/contrib/debug/browser/baseDebugView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function renderExpressionValue(expressionOrValue: IExpressionContainer |
9292
if (options.linkDetector) {
9393
container.textContent = '';
9494
const session = (expressionOrValue instanceof ExpressionContainer) ? expressionOrValue.getSession() : undefined;
95-
container.appendChild(options.linkDetector.linkify(value, false, session ? session.root : undefined));
95+
container.appendChild(options.linkDetector.linkify(value, false, session ? session.root : undefined, true));
9696
} else {
9797
container.textContent = value;
9898
}

src/vs/workbench/contrib/debug/browser/linkDetector.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class LinkDetector {
5757
* When splitLines is true, each line of the text, even if it contains no links, is wrapped in a <span>
5858
* and added as a child of the returned <span>.
5959
*/
60-
linkify(text: string, splitLines?: boolean, workspaceFolder?: IWorkspaceFolder): HTMLElement {
60+
linkify(text: string, splitLines?: boolean, workspaceFolder?: IWorkspaceFolder, includeFulltext?: boolean): HTMLElement {
6161
if (splitLines) {
6262
const lines = text.split('\n');
6363
for (let i = 0; i < lines.length - 1; i++) {
@@ -67,7 +67,7 @@ export class LinkDetector {
6767
// Remove the last element ('') that split added.
6868
lines.pop();
6969
}
70-
const elements = lines.map(line => this.linkify(line, false, workspaceFolder));
70+
const elements = lines.map(line => this.linkify(line, false, workspaceFolder, includeFulltext));
7171
if (elements.length === 1) {
7272
// Do not wrap single line with extra span.
7373
return elements[0];
@@ -85,13 +85,13 @@ export class LinkDetector {
8585
container.appendChild(document.createTextNode(part.value));
8686
break;
8787
case 'web':
88-
container.appendChild(this.createWebLink(part.value));
88+
container.appendChild(this.createWebLink(includeFulltext ? text : undefined, part.value));
8989
break;
9090
case 'path': {
9191
const path = part.captures[0];
9292
const lineNumber = part.captures[1] ? Number(part.captures[1]) : 0;
9393
const columnNumber = part.captures[2] ? Number(part.captures[2]) : 0;
94-
container.appendChild(this.createPathLink(part.value, path, lineNumber, columnNumber, workspaceFolder));
94+
container.appendChild(this.createPathLink(includeFulltext ? text : undefined, part.value, path, lineNumber, columnNumber, workspaceFolder));
9595
break;
9696
}
9797
}
@@ -102,7 +102,7 @@ export class LinkDetector {
102102
return container;
103103
}
104104

105-
private createWebLink(url: string): Node {
105+
private createWebLink(fulltext: string | undefined, url: string): Node {
106106
const link = this.createLink(url);
107107

108108
let uri = URI.parse(url);
@@ -116,7 +116,7 @@ export class LinkDetector {
116116
});
117117
}
118118

119-
this.decorateLink(link, uri, async () => {
119+
this.decorateLink(link, uri, fulltext, async () => {
120120

121121
if (uri.scheme === Schemas.file) {
122122
// Just using fsPath here is unsafe: https://github.com/microsoft/vscode/issues/109076
@@ -146,7 +146,7 @@ export class LinkDetector {
146146
return link;
147147
}
148148

149-
private createPathLink(text: string, path: string, lineNumber: number, columnNumber: number, workspaceFolder: IWorkspaceFolder | undefined): Node {
149+
private createPathLink(fulltext: string | undefined, text: string, path: string, lineNumber: number, columnNumber: number, workspaceFolder: IWorkspaceFolder | undefined): Node {
150150
if (path[0] === '/' && path[1] === '/') {
151151
// Most likely a url part which did not match, for example ftp://path.
152152
return document.createTextNode(text);
@@ -159,7 +159,7 @@ export class LinkDetector {
159159
}
160160
const uri = workspaceFolder.toResource(path);
161161
const link = this.createLink(text);
162-
this.decorateLink(link, uri, (preserveFocus: boolean) => this.editorService.openEditor({ resource: uri, options: { ...options, preserveFocus } }));
162+
this.decorateLink(link, uri, fulltext, (preserveFocus: boolean) => this.editorService.openEditor({ resource: uri, options: { ...options, preserveFocus } }));
163163
return link;
164164
}
165165

@@ -177,7 +177,7 @@ export class LinkDetector {
177177
if (stat.isDirectory) {
178178
return;
179179
}
180-
this.decorateLink(link, uri, (preserveFocus: boolean) => this.editorService.openEditor({ resource: uri, options: { ...options, preserveFocus } }));
180+
this.decorateLink(link, uri, fulltext, (preserveFocus: boolean) => this.editorService.openEditor({ resource: uri, options: { ...options, preserveFocus } }));
181181
}).catch(() => {
182182
// If the uri can not be resolved we should not spam the console with error, remain quite #86587
183183
});
@@ -190,10 +190,12 @@ export class LinkDetector {
190190
return link;
191191
}
192192

193-
private decorateLink(link: HTMLElement, uri: URI, onClick: (preserveFocus: boolean) => void) {
193+
private decorateLink(link: HTMLElement, uri: URI, fulltext: string | undefined, onClick: (preserveFocus: boolean) => void) {
194194
link.classList.add('link');
195195
const followLink = this.tunnelService.canTunnel(uri) ? localize('followForwardedLink', "follow link using forwarded port") : localize('followLink', "follow link");
196-
link.title = platform.isMacintosh ? localize('fileLinkMac', "Cmd + click to {0}", followLink) : localize('fileLink', "Ctrl + click to {0}", followLink);
196+
link.title = fulltext
197+
? (platform.isMacintosh ? localize('fileLinkWithPathMac', "Cmd + click to {0}\n{1}", followLink, fulltext) : localize('fileLinkWithPath', "Ctrl + click to {0}\n{1}", followLink, fulltext))
198+
: (platform.isMacintosh ? localize('fileLinkMac', "Cmd + click to {0}", followLink) : localize('fileLink', "Ctrl + click to {0}", followLink));
197199
link.onmousemove = (event) => { link.classList.toggle('pointer', platform.isMacintosh ? event.metaKey : event.ctrlKey); };
198200
link.onmouseleave = () => link.classList.remove('pointer');
199201
link.onclick = (event) => {

0 commit comments

Comments
 (0)