Skip to content

Commit 4a9ec29

Browse files
authored
Merge pull request microsoft#181919 from microsoft/tyriar/179972
Improve trace logging in local link detector
2 parents 9d0b7ce + a9d434a commit 4a9ec29

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ITerminalCapabilityStore, TerminalCapability } from 'vs/platform/termin
1313
import { IBufferLine, IBufferRange, Terminal } from 'xterm';
1414
import { ITerminalBackend, ITerminalProcessManager } from 'vs/workbench/contrib/terminal/common/terminal';
1515
import { detectLinks } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing';
16+
import { ILogService } from 'vs/platform/log/common/log';
1617

1718
const enum Constants {
1819
/**
@@ -69,6 +70,7 @@ export class TerminalLocalLinkDetector implements ITerminalLinkDetector {
6970
private readonly _capabilities: ITerminalCapabilityStore,
7071
private readonly _processManager: Pick<ITerminalProcessManager, 'initialCwd' | 'os' | 'remoteAuthority' | 'userHome'> & { backend?: Pick<ITerminalBackend, 'getWslPath'> },
7172
private readonly _linkResolver: ITerminalLinkResolver,
73+
@ILogService private readonly _logService: ILogService,
7274
@IUriIdentityService private readonly _uriIdentityService: IUriIdentityService,
7375
@IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService
7476
) {
@@ -88,7 +90,10 @@ export class TerminalLocalLinkDetector implements ITerminalLinkDetector {
8890

8991
const os = this._processManager.os || OS;
9092
const parsedLinks = detectLinks(text, os);
93+
this._logService.trace('terminalLocaLinkDetector#detect text', text);
94+
this._logService.trace('terminalLocaLinkDetector#detect parsedLinks', parsedLinks);
9195
for (const parsedLink of parsedLinks) {
96+
9297
// Don't try resolve any links of excessive length
9398
if (parsedLink.path.text.length > Constants.MaxResolvedLinkLength) {
9499
continue;
@@ -147,6 +152,7 @@ export class TerminalLocalLinkDetector implements ITerminalLinkDetector {
147152
}
148153
}
149154
linkCandidates.push(...specialEndLinkCandidates);
155+
this._logService.trace('terminalLocaLinkDetector#detect linkCandidates', linkCandidates);
150156

151157
// Validate the path and convert to the outgoing type
152158
const simpleLink = await this._validateAndGetLink(undefined, bufferRange, linkCandidates, trimRangeMap);
@@ -156,6 +162,7 @@ export class TerminalLocalLinkDetector implements ITerminalLinkDetector {
156162
parsedLink.prefix?.index ?? parsedLink.path.index,
157163
parsedLink.suffix ? parsedLink.suffix.suffix.index + parsedLink.suffix.suffix.text.length : parsedLink.path.index + parsedLink.path.text.length
158164
);
165+
this._logService.trace('terminalLocaLinkDetector#detect verified link', simpleLink);
159166
links.push(simpleLink);
160167
}
161168

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { TerminalLinkResolver } from 'vs/workbench/contrib/terminalContrib/links
1919
import { IFileService } from 'vs/platform/files/common/files';
2020
import { createFileStat } from 'vs/workbench/test/common/workbenchTestServices';
2121
import { URI } from 'vs/base/common/uri';
22+
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
2223

2324
const unixLinks: (string | { link: string; resource: URI })[] = [
2425
// Absolute
@@ -181,6 +182,7 @@ suite('Workbench - TerminalLocalLinkDetector', () => {
181182
return createFileStat(resource);
182183
}
183184
});
185+
instantiationService.stub(ILogService, new NullLogService());
184186
resolver = instantiationService.createInstance(TerminalLinkResolver);
185187
validResources = [];
186188

0 commit comments

Comments
 (0)