From 9901d2b7fbcd4c40fc828404fd4354f16fe06fc9 Mon Sep 17 00:00:00 2001 From: Michel Kaporin Date: Fri, 5 May 2017 16:16:35 +0200 Subject: [PATCH] Removed redundant instantiations of LinkDetetector for each ANSI output. Corrected regex description. --- src/vs/workbench/parts/debug/browser/linkDetector.ts | 2 +- .../parts/debug/electron-browser/replViewer.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/parts/debug/browser/linkDetector.ts b/src/vs/workbench/parts/debug/browser/linkDetector.ts index 55657a24827..e75ea509664 100644 --- a/src/vs/workbench/parts/debug/browser/linkDetector.ts +++ b/src/vs/workbench/parts/debug/browser/linkDetector.ts @@ -15,7 +15,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace export class LinkDetector { private static FILE_LOCATION_PATTERNS: RegExp[] = [ // group 0: full path with line and column - // group 1: full path without line and column, matched by `*.*` in the end to work only on paths with extensions in the end (s.t. http://test.com:8000 would not match) + // group 1: full path without line and column, matched by `*.*` in the end to work only on paths with extensions in the end (s.t. node:10352 would not match) // group 2: drive letter on windows with trailing backslash or leading slash on mac/linux // group 3: line number, matched by (:(\d+)) // group 4: column number, matched by ((?::(\d+))?) diff --git a/src/vs/workbench/parts/debug/electron-browser/replViewer.ts b/src/vs/workbench/parts/debug/electron-browser/replViewer.ts index f9fa4c9fbdd..3442772f59c 100644 --- a/src/vs/workbench/parts/debug/electron-browser/replViewer.ts +++ b/src/vs/workbench/parts/debug/electron-browser/replViewer.ts @@ -86,11 +86,13 @@ export class ReplExpressionsRenderer implements IRenderer { private width: number; private characterWidth: number; + private linkDetector: LinkDetector; + constructor( @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IInstantiationService private instantiationService: IInstantiationService ) { - // noop + this.linkDetector = this.instantiationService.createInstance(LinkDetector); } public getHeight(tree: ITree, element: any): number { @@ -319,8 +321,7 @@ export class ReplExpressionsRenderer implements IRenderer { // flush text buffer if we have any if (buffer) { - const linkDetector = this.instantiationService.createInstance(LinkDetector); - this.insert(linkDetector.handleLinks(buffer), currentToken || tokensContainer); + this.insert(this.linkDetector.handleLinks(buffer), currentToken || tokensContainer); buffer = ''; } @@ -340,8 +341,7 @@ export class ReplExpressionsRenderer implements IRenderer { // flush remaining text buffer if we have any if (buffer) { - const linkDetector = this.instantiationService.createInstance(LinkDetector); - let res = linkDetector.handleLinks(buffer); + let res = this.linkDetector.handleLinks(buffer); if (typeof res !== 'string' || currentToken) { if (!tokensContainer) { tokensContainer = document.createElement('span'); -- GitLab