From f5568c94f8c743dbbbc451f9682be5370f7bbbea Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 15 May 2020 16:50:43 -0700 Subject: [PATCH 1/9] Remove link matchers from terminal Part of #96266 --- .../tasks/browser/terminalTaskSystem.ts | 37 ---- .../browser/links/terminalLinkManager.ts | 200 +----------------- .../terminalValidatedLocalLinkProvider.ts | 15 +- .../contrib/terminal/browser/terminal.ts | 20 -- .../terminal/browser/terminalInstance.ts | 10 +- .../browser/links/terminalLinkManager.test.ts | 35 --- 6 files changed, 18 insertions(+), 299 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts index c301d2fdb1108..3bb82ced091af 100644 --- a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts @@ -725,7 +725,6 @@ export class TerminalTaskSystem implements ITaskSystem { // The process never got ready. Need to think how to handle this. }); this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.Start, task, terminal.id)); - const registeredLinkMatchers = this.registerLinkMatchers(terminal, problemMatchers); let skipLine: boolean = (!!task.command.presentation && task.command.presentation.echo); const onData = terminal.onLineData((line) => { if (skipLine) { @@ -770,7 +769,6 @@ export class TerminalTaskSystem implements ITaskSystem { } watchingProblemMatcher.done(); watchingProblemMatcher.dispose(); - registeredLinkMatchers.forEach(handle => terminal!.deregisterLinkMatcher(handle)); if (!processStartedSignaled) { this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.ProcessStarted, task, terminal!.processId!)); processStartedSignaled = true; @@ -813,7 +811,6 @@ export class TerminalTaskSystem implements ITaskSystem { this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.Active, task)); let problemMatchers = this.resolveMatchers(resolver, task.configurationProperties.problemMatchers); let startStopProblemMatcher = new StartStopProblemCollector(problemMatchers, this.markerService, this.modelService, ProblemHandlingStrategy.Clean, this.fileService); - const registeredLinkMatchers = this.registerLinkMatchers(terminal, problemMatchers); let skipLine: boolean = (!!task.command.presentation && task.command.presentation.echo); const onData = terminal.onLineData((line) => { if (skipLine) { @@ -852,11 +849,6 @@ export class TerminalTaskSystem implements ITaskSystem { } startStopProblemMatcher.done(); startStopProblemMatcher.dispose(); - registeredLinkMatchers.forEach(handle => { - if (terminal) { - terminal.deregisterLinkMatcher(handle); - } - }); if (!processStartedSignaled && terminal) { this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.ProcessStarted, task, terminal.processId!)); processStartedSignaled = true; @@ -1477,35 +1469,6 @@ export class TerminalTaskSystem implements ITaskSystem { return result; } - private registerLinkMatchers(terminal: ITerminalInstance, problemMatchers: ProblemMatcher[]): number[] { - let result: number[] = []; - /* - let handlePattern = (matcher: ProblemMatcher, pattern: ProblemPattern): void => { - if (pattern.regexp instanceof RegExp && Types.isNumber(pattern.file)) { - result.push(terminal.registerLinkMatcher(pattern.regexp, (match: string) => { - let resource: URI = getResource(match, matcher); - if (resource) { - this.workbenchEditorService.openEditor({ - resource: resource - }); - } - }, 0)); - } - }; - - for (let problemMatcher of problemMatchers) { - if (Array.isArray(problemMatcher.pattern)) { - for (let pattern of problemMatcher.pattern) { - handlePattern(problemMatcher, pattern); - } - } else if (problemMatcher.pattern) { - handlePattern(problemMatcher, problemMatcher.pattern); - } - } - */ - return result; - } - private static WellKnowCommands: IStringDictionary = { 'ant': true, 'cmake': true, diff --git a/src/vs/workbench/contrib/terminal/browser/links/terminalLinkManager.ts b/src/vs/workbench/contrib/terminal/browser/links/terminalLinkManager.ts index c8e0235f257a1..208b05dbed92b 100644 --- a/src/vs/workbench/contrib/terminal/browser/links/terminalLinkManager.ts +++ b/src/vs/workbench/contrib/terminal/browser/links/terminalLinkManager.ts @@ -5,69 +5,30 @@ import * as nls from 'vs/nls'; import { URI } from 'vs/base/common/uri'; -import { DisposableStore, IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { DisposableStore, IDisposable } from 'vs/base/common/lifecycle'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/widgets/widgetManager'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { ITerminalProcessManager, ITerminalConfigHelper, ITerminalConfiguration, TERMINAL_CONFIG_SECTION } from 'vs/workbench/contrib/terminal/common/terminal'; +import { ITerminalProcessManager, ITerminalConfiguration, TERMINAL_CONFIG_SECTION } from 'vs/workbench/contrib/terminal/common/terminal'; import { ITextEditorSelection } from 'vs/platform/editor/common/editor'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IFileService } from 'vs/platform/files/common/files'; -import { Terminal, ILinkMatcherOptions, IViewportRange, ITerminalAddon } from 'xterm'; +import { Terminal, IViewportRange } from 'xterm'; import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts'; import { posix, win32 } from 'vs/base/common/path'; -import { ITerminalInstanceService, ITerminalBeforeHandleLinkEvent, LINK_INTERCEPT_THRESHOLD } from 'vs/workbench/contrib/terminal/browser/terminal'; +import { ITerminalBeforeHandleLinkEvent, LINK_INTERCEPT_THRESHOLD } from 'vs/workbench/contrib/terminal/browser/terminal'; import { OperatingSystem, isMacintosh, OS } from 'vs/base/common/platform'; import { IMarkdownString, MarkdownString } from 'vs/base/common/htmlContent'; import { Emitter, Event } from 'vs/base/common/event'; import { ILogService } from 'vs/platform/log/common/log'; import { TerminalProtocolLinkProvider } from 'vs/workbench/contrib/terminal/browser/links/terminalProtocolLinkProvider'; -import { TerminalValidatedLocalLinkProvider } from 'vs/workbench/contrib/terminal/browser/links/terminalValidatedLocalLinkProvider'; +import { TerminalValidatedLocalLinkProvider, lineAndColumnClause, unixLocalLinkClause, winLocalLinkClause, winDrivePrefix, winLineAndColumnMatchIndex, unixLineAndColumnMatchIndex, lineAndColumnClauseGroupCount } from 'vs/workbench/contrib/terminal/browser/links/terminalValidatedLocalLinkProvider'; import { TerminalWordLinkProvider } from 'vs/workbench/contrib/terminal/browser/links/terminalWordLinkProvider'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { XTermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private'; import { TerminalHover, ILinkHoverTargetOptions } from 'vs/workbench/contrib/terminal/browser/widgets/terminalHoverWidget'; import { TerminalLink } from 'vs/workbench/contrib/terminal/browser/links/terminalLink'; -const pathPrefix = '(\\.\\.?|\\~)'; -const pathSeparatorClause = '\\/'; -// '":; are allowed in paths but they are often separators so ignore them -// Also disallow \\ to prevent a catastropic backtracking case #24798 -const excludedPathCharactersClause = '[^\\0\\s!$`&*()\\[\\]+\'":;\\\\]'; -/** A regex that matches paths in the form /foo, ~/foo, ./foo, ../foo, foo/bar */ -const unixLocalLinkClause = '((' + pathPrefix + '|(' + excludedPathCharactersClause + ')+)?(' + pathSeparatorClause + '(' + excludedPathCharactersClause + ')+)+)'; - -// Valid absolute formats: C:, \\?\C: and \\?\%VAR% -const winDrivePrefix = '(?:\\\\\\\\\\?\\\\)?[a-zA-Z]:'; -const winPathPrefix = '(' + winDrivePrefix + '|\\.\\.?|\\~)'; -const winPathSeparatorClause = '(\\\\|\\/)'; -const winExcludedPathCharactersClause = '[^\\0<>\\?\\|\\/\\s!$`&*()\\[\\]+\'":;]'; -/** A regex that matches paths in the form \\?\c:\foo c:\foo, ~\foo, .\foo, ..\foo, foo\bar */ -const winLocalLinkClause = '((' + winPathPrefix + '|(' + winExcludedPathCharactersClause + ')+)?(' + winPathSeparatorClause + '(' + winExcludedPathCharactersClause + ')+)+)'; - -/** As xterm reads from DOM, space in that case is nonbreaking char ASCII code - 160, -replacing space with nonBreakningSpace or space ASCII code - 32. */ -const lineAndColumnClause = [ - '((\\S*)", line ((\\d+)( column (\\d+))?))', // "(file path)", line 45 [see #40468] - '((\\S*)",((\\d+)(:(\\d+))?))', // "(file path)",45 [see #78205] - '((\\S*) on line ((\\d+)(, column (\\d+))?))', // (file path) on line 8, column 13 - '((\\S*):line ((\\d+)(, column (\\d+))?))', // (file path):line 8, column 13 - '(([^\\s\\(\\)]*)(\\s?[\\(\\[](\\d+)(,\\s?(\\d+))?)[\\)\\]])', // (file path)(45), (file path) (45), (file path)(45,18), (file path) (45,18), (file path)(45, 18), (file path) (45, 18), also with [] - '(([^:\\s\\(\\)<>\'\"\\[\\]]*)(:(\\d+))?(:(\\d+))?)' // (file path):336, (file path):336:9 -].join('|').replace(/ /g, `[${'\u00A0'} ]`); - -// Changing any regex may effect this value, hence changes this as well if required. -const winLineAndColumnMatchIndex = 12; -const unixLineAndColumnMatchIndex = 11; - -// Each line and column clause have 6 groups (ie no. of expressions in round brackets) -const lineAndColumnClauseGroupCount = 6; - -/** Higher than local link, lower than hypertext */ -const CUSTOM_LINK_PRIORITY = -1; -/** Lowest */ -const LOCAL_LINK_PRIORITY = -2; - export type XtermLinkMatcherHandler = (event: MouseEvent | undefined, link: string) => Promise; export type XtermLinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void; @@ -82,10 +43,6 @@ interface IPath { export class TerminalLinkManager extends DisposableStore { private _widgetManager: TerminalWidgetManager | undefined; private _processCwd: string | undefined; - private _gitDiffPreImagePattern: RegExp; - private _gitDiffPostImagePattern: RegExp; - private _linkMatchers: number[] = []; - private _webLinksAddon: ITerminalAddon | undefined; private _linkProviders: IDisposable[] = []; private _hasBeforeHandleLinkListeners = false; @@ -106,62 +63,16 @@ export class TerminalLinkManager extends DisposableStore { constructor( private _xterm: Terminal, private readonly _processManager: ITerminalProcessManager, - private readonly _configHelper: ITerminalConfigHelper, @IOpenerService private readonly _openerService: IOpenerService, @IEditorService private readonly _editorService: IEditorService, @IConfigurationService private readonly _configurationService: IConfigurationService, - @ITerminalInstanceService private readonly _terminalInstanceService: ITerminalInstanceService, @IFileService private readonly _fileService: IFileService, @ILogService private readonly _logService: ILogService, @IInstantiationService private readonly _instantiationService: IInstantiationService ) { super(); - // Matches '--- a/src/file1', capturing 'src/file1' in group 1 - this._gitDiffPreImagePattern = /^--- a\/(\S*)/; - // Matches '+++ b/src/file1', capturing 'src/file1' in group 1 - this._gitDiffPostImagePattern = /^\+\+\+ b\/(\S*)/; - - if (this._configHelper.config.experimentalLinkProvider) { - this.registerLinkProvider(); - } else { - this._registerLinkMatchers(); - } - - this._configurationService?.onDidChangeConfiguration(e => { - if (e.affectsConfiguration('terminal.integrated.experimentalLinkProvider')) { - if (this._configHelper.config.experimentalLinkProvider) { - this._deregisterLinkMatchers(); - this.registerLinkProvider(); - } else { - dispose(this._linkProviders); - this._linkProviders.length = 0; - this._registerLinkMatchers(); - } - } - }); - } - - private _tooltipCallback(linkText: string, viewportRange: IViewportRange, linkHandler: (url: string) => void) { - if (!this._widgetManager) { - return; - } - - const core = (this._xterm as any)._core as XTermCore; - const cellDimensions = { - width: core._renderService.dimensions.actualCellWidth, - height: core._renderService.dimensions.actualCellHeight - }; - const terminalDimensions = { - width: this._xterm.cols, - height: this._xterm.rows - }; - - this._showHover({ - viewportRange, - cellDimensions, - terminalDimensions - }, this._getLinkHoverString(linkText, undefined), linkHandler); + this.registerLinkProvider(); } private _tooltipCallback2(link: TerminalLink, viewportRange: IViewportRange, modifierDownCallback?: () => void, modifierUpCallback?: () => void) { @@ -204,24 +115,6 @@ export class TerminalLinkManager extends DisposableStore { } } - private _registerLinkMatchers() { - this.registerWebLinkHandler(); - if (this._processManager) { - if (this._configHelper.config.enableFileLinks) { - this.registerLocalLinkHandler(); - } - this.registerGitDiffLinkHandlers(); - } - } - - private _deregisterLinkMatchers() { - this._webLinksAddon?.dispose(); - - this._linkMatchers.forEach(matcherId => { - this._xterm.deregisterLinkMatcher(matcherId); - }); - } - public setWidgetManager(widgetManager: TerminalWidgetManager): void { this._widgetManager = widgetManager; } @@ -230,71 +123,6 @@ export class TerminalLinkManager extends DisposableStore { this._processCwd = processCwd; } - public registerCustomLinkHandler(regex: RegExp, handler: (event: MouseEvent | undefined, uri: string) => void, matchIndex?: number, validationCallback?: XtermLinkMatcherValidationCallback): number { - const tooltipCallback = (_: MouseEvent, linkText: string, location: IViewportRange) => { - this._tooltipCallback(linkText, location, text => handler(undefined, text)); - }; - const options: ILinkMatcherOptions = { - matchIndex, - tooltipCallback, - willLinkActivate: (e: MouseEvent) => this._isLinkActivationModifierDown(e), - priority: CUSTOM_LINK_PRIORITY - }; - if (validationCallback) { - options.validationCallback = (uri: string, callback: (isValid: boolean) => void) => validationCallback(uri, callback); - } - return this._xterm.registerLinkMatcher(regex, this._wrapLinkHandler(handler), options); - } - - public registerWebLinkHandler(): void { - this._terminalInstanceService.getXtermWebLinksConstructor().then((WebLinksAddon) => { - if (!this._xterm) { - return; - } - const wrappedHandler = this._wrapLinkHandler((_, link) => this._handleHypertextLink(link)); - const tooltipCallback = (_: MouseEvent, linkText: string, location: IViewportRange) => { - this._tooltipCallback(linkText, location, this._handleHypertextLink.bind(this)); - }; - this._webLinksAddon = new WebLinksAddon(wrappedHandler, { - validationCallback: (uri: string, callback: (isValid: boolean) => void) => this._validateWebLink(callback), - tooltipCallback, - willLinkActivate: (e: MouseEvent) => this._isLinkActivationModifierDown(e) - }); - this._xterm.loadAddon(this._webLinksAddon); - }); - } - - public registerLocalLinkHandler(): void { - const wrappedHandler = this._wrapLinkHandler((_, url) => this._handleLocalLink(url)); - const tooltipCallback = (event: MouseEvent, linkText: string, location: IViewportRange) => { - this._tooltipCallback(linkText, location, this._handleLocalLink.bind(this)); - }; - this._linkMatchers.push(this._xterm.registerLinkMatcher(this._localLinkRegex, wrappedHandler, { - validationCallback: (uri: string, callback: (isValid: boolean) => void) => this._validateLocalLink(uri, callback), - tooltipCallback, - willLinkActivate: (e: MouseEvent) => this._isLinkActivationModifierDown(e), - priority: LOCAL_LINK_PRIORITY - })); - } - - public registerGitDiffLinkHandlers(): void { - const wrappedHandler = this._wrapLinkHandler((_, url) => { - this._handleLocalLink(url); - }); - const tooltipCallback = (event: MouseEvent, linkText: string, location: IViewportRange) => { - this._tooltipCallback(linkText, location, this._handleLocalLink.bind(this)); - }; - const options = { - matchIndex: 1, - validationCallback: (uri: string, callback: (isValid: boolean) => void) => this._validateLocalLink(uri, callback), - tooltipCallback, - willLinkActivate: (e: MouseEvent) => this._isLinkActivationModifierDown(e), - priority: LOCAL_LINK_PRIORITY - }; - this._linkMatchers.push(this._xterm.registerLinkMatcher(this._gitDiffPreImagePattern, wrappedHandler, options)); - this._linkMatchers.push(this._xterm.registerLinkMatcher(this._gitDiffPostImagePattern, wrappedHandler, options)); - } - public registerLinkProvider(): void { // Protocol links const wrappedActivateCallback = this._wrapLinkHandler((_, link) => this._handleProtocolLink(link)); @@ -370,14 +198,6 @@ export class TerminalLinkManager extends DisposableStore { return new RegExp(`${baseLocalLinkClause}(${lineAndColumnClause})`); } - protected get _gitDiffPreImageRegex(): RegExp { - return this._gitDiffPreImagePattern; - } - - protected get _gitDiffPostImageRegex(): RegExp { - return this._gitDiffPostImagePattern; - } - private async _handleLocalLink(link: string): Promise { // TODO: This gets resolved again but doesn't need to as it's already validated const resolvedLink = await this._resolvePath(link); @@ -392,14 +212,6 @@ export class TerminalLinkManager extends DisposableStore { await this._editorService.openEditor({ resource: resolvedLink.uri, options: { pinned: true, selection } }); } - private _validateLocalLink(link: string, callback: (isValid: boolean) => void): void { - this._resolvePath(link).then(resolvedLink => callback(!!resolvedLink)); - } - - private _validateWebLink(callback: (isValid: boolean) => void): void { - callback(true); - } - private _handleHypertextLink(url: string): void { this._openerService.open(url, { allowTunneling: !!(this._processManager && this._processManager.remoteAuthority) }); } diff --git a/src/vs/workbench/contrib/terminal/browser/links/terminalValidatedLocalLinkProvider.ts b/src/vs/workbench/contrib/terminal/browser/links/terminalValidatedLocalLinkProvider.ts index 55dc5d26fcd26..287afdf9e1a02 100644 --- a/src/vs/workbench/contrib/terminal/browser/links/terminalValidatedLocalLinkProvider.ts +++ b/src/vs/workbench/contrib/terminal/browser/links/terminalValidatedLocalLinkProvider.ts @@ -22,18 +22,18 @@ const pathSeparatorClause = '\\/'; // Also disallow \\ to prevent a catastropic backtracking case #24798 const excludedPathCharactersClause = '[^\\0\\s!$`&*()\\[\\]+\'":;\\\\]'; /** A regex that matches paths in the form /foo, ~/foo, ./foo, ../foo, foo/bar */ -const unixLocalLinkClause = '((' + pathPrefix + '|(' + excludedPathCharactersClause + ')+)?(' + pathSeparatorClause + '(' + excludedPathCharactersClause + ')+)+)'; +export const unixLocalLinkClause = '((' + pathPrefix + '|(' + excludedPathCharactersClause + ')+)?(' + pathSeparatorClause + '(' + excludedPathCharactersClause + ')+)+)'; -const winDrivePrefix = '(?:\\\\\\\\\\?\\\\)?[a-zA-Z]:'; +export const winDrivePrefix = '(?:\\\\\\\\\\?\\\\)?[a-zA-Z]:'; const winPathPrefix = '(' + winDrivePrefix + '|\\.\\.?|\\~)'; const winPathSeparatorClause = '(\\\\|\\/)'; const winExcludedPathCharactersClause = '[^\\0<>\\?\\|\\/\\s!$`&*()\\[\\]+\'":;]'; /** A regex that matches paths in the form \\?\c:\foo c:\foo, ~\foo, .\foo, ..\foo, foo\bar */ -const winLocalLinkClause = '((' + winPathPrefix + '|(' + winExcludedPathCharactersClause + ')+)?(' + winPathSeparatorClause + '(' + winExcludedPathCharactersClause + ')+)+)'; +export const winLocalLinkClause = '((' + winPathPrefix + '|(' + winExcludedPathCharactersClause + ')+)?(' + winPathSeparatorClause + '(' + winExcludedPathCharactersClause + ')+)+)'; /** As xterm reads from DOM, space in that case is nonbreaking char ASCII code - 160, replacing space with nonBreakningSpace or space ASCII code - 32. */ -const lineAndColumnClause = [ +export const lineAndColumnClause = [ '((\\S*)", line ((\\d+)( column (\\d+))?))', // "(file path)", line 45 [see #40468] '((\\S*)",((\\d+)(:(\\d+))?))', // "(file path)",45 [see #78205] '((\\S*) on line ((\\d+)(, column (\\d+))?))', // (file path) on line 8, column 13 @@ -42,6 +42,13 @@ const lineAndColumnClause = [ '(([^:\\s\\(\\)<>\'\"\\[\\]]*)(:(\\d+))?(:(\\d+))?)' // (file path):336, (file path):336:9 ].join('|').replace(/ /g, `[${'\u00A0'} ]`); +// Changing any regex may effect this value, hence changes this as well if required. +export const winLineAndColumnMatchIndex = 12; +export const unixLineAndColumnMatchIndex = 11; + +// Each line and column clause have 6 groups (ie no. of expressions in round brackets) +export const lineAndColumnClauseGroupCount = 6; + export class TerminalValidatedLocalLinkProvider extends TerminalBaseLinkProvider { constructor( private readonly _xterm: Terminal, diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.ts b/src/vs/workbench/contrib/terminal/browser/terminal.ts index 7cdaa84832df2..d06119f17656b 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.ts @@ -338,26 +338,6 @@ export interface ITerminalInstance { */ forceRedraw(): void; - /** - * Registers a link matcher, allowing custom link patterns to be matched and handled. - * @param regex The regular expression the search for, specifically this searches the - * textContent of the rows. You will want to use \s to match a space ' ' character for example. - * @param handler The callback when the link is called. - * @param matchIndex The index of the link from the regex.match(html) call. This defaults to 0 - * (for regular expressions without capture groups). - * @param validationCallback A callback which can be used to validate the link after it has been - * added to the DOM. - * @return The ID of the new matcher, this can be used to deregister. - */ - registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number, validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void): number; - - /** - * Deregisters a link matcher if it has been registered. - * @param matcherId The link matcher's ID (returned after register) - * @return Whether a link matcher was found and deregistered. - */ - deregisterLinkMatcher(matcherId: number): void; - /** * Check if anything is selected in terminal. */ diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 4d942a3cd0fc0..23b50a8050f0d 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -408,7 +408,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { return false; }); } - this._linkManager = this._instantiationService.createInstance(TerminalLinkManager, xterm, this._processManager!, this._configHelper); + this._linkManager = this._instantiationService.createInstance(TerminalLinkManager, xterm, this._processManager!); this._linkManager.onBeforeHandleLink(e => { e.terminal = this; this._onBeforeHandleLink.fire(e); @@ -656,14 +656,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { }; } - public registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number, validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void): number { - return this._linkManager!.registerCustomLinkHandler(regex, (_, url) => handler(url), matchIndex, validationCallback); - } - - public deregisterLinkMatcher(linkMatcherId: number): void { - this._xtermReadyPromise.then(xterm => xterm.deregisterLinkMatcher(linkMatcherId)); - } - public hasSelection(): boolean { return this._xterm ? this._xterm.hasSelection() : false; } diff --git a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts index b5e5a01c9a06c..7c8b7b25ec118 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts @@ -21,12 +21,6 @@ class TestTerminalLinkManager extends TerminalLinkManager { public get localLinkRegex(): RegExp { return this._localLinkRegex; } - public get gitDiffLinkPreImageRegex(): RegExp { - return this._gitDiffPreImageRegex; - } - public get gitDiffLinkPostImageRegex(): RegExp { - return this._gitDiffPostImageRegex; - } public preprocessPath(link: string): string | null { return this._preprocessPath(link); } @@ -299,35 +293,6 @@ suite('Workbench - TerminalLinkHandler', () => { }); }); - test('gitDiffLinkRegex', () => { - // The platform is irrelevant because the links generated by Git are the same format regardless of platform - const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { - os: OperatingSystem.Linux, - userHome: '' - } as any, testConfigHelper); - - function assertAreGoodMatches(matches: RegExpMatchArray | null) { - if (matches) { - assert.equal(matches.length, 2); - assert.equal(matches[1], 'src/file1'); - } else { - assert.fail(); - } - } - - // Happy cases - assertAreGoodMatches('--- a/src/file1'.match(linkHandler.gitDiffLinkPreImageRegex)); - assertAreGoodMatches('--- a/src/file1 '.match(linkHandler.gitDiffLinkPreImageRegex)); - assertAreGoodMatches('+++ b/src/file1'.match(linkHandler.gitDiffLinkPostImageRegex)); - assertAreGoodMatches('+++ b/src/file1 '.match(linkHandler.gitDiffLinkPostImageRegex)); - - // Make sure /dev/null isn't a match - assert.equal(linkHandler.gitDiffLinkPreImageRegex.test('--- /dev/null'), false); - assert.equal(linkHandler.gitDiffLinkPreImageRegex.test('--- /dev/null '), false); - assert.equal(linkHandler.gitDiffLinkPostImageRegex.test('+++ /dev/null'), false); - assert.equal(linkHandler.gitDiffLinkPostImageRegex.test('+++ /dev/null '), false); - }); - suite('wrapLinkHandler', () => { const nullMouseEvent: any = Object.freeze({ preventDefault: () => { } }); From 3f27e5123332def803eb6c9dbab92af77c4db10d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 15 May 2020 16:53:33 -0700 Subject: [PATCH 2/9] Fix test instantiation conflict --- .../browser/links/terminalLinkManager.test.ts | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts index 7c8b7b25ec118..eda9209708a96 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts @@ -9,7 +9,6 @@ import { TerminalLinkManager, LineColumnInfo, XtermLinkMatcherHandler } from 'vs import * as strings from 'vs/base/common/strings'; import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal'; import { Event } from 'vs/base/common/event'; -import { ITerminalConfigHelper } from 'vs/workbench/contrib/terminal/common/terminal'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; import { TestPathService, TestEnvironmentService } from 'vs/workbench/test/browser/workbenchTestServices'; import { IPathService } from 'vs/workbench/services/path/common/pathService'; @@ -76,12 +75,6 @@ interface LinkFormatInfo { column?: string; } -const testConfigHelper: ITerminalConfigHelper = { - config: { - enableFileLinks: true - } -}; - suite('Workbench - TerminalLinkHandler', () => { let instantiationService: TestInstantiationService; @@ -98,7 +91,7 @@ suite('Workbench - TerminalLinkHandler', () => { const terminalLinkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm(), { os: OperatingSystem.Windows, userHome: '' - } as any, testConfigHelper); + } as any); function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) { assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl); assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl); @@ -175,7 +168,7 @@ suite('Workbench - TerminalLinkHandler', () => { const terminalLinkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm(), { os: OperatingSystem.Linux, userHome: '' - } as any, testConfigHelper); + } as any); function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) { assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl); assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl); @@ -243,7 +236,7 @@ suite('Workbench - TerminalLinkHandler', () => { const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { os: OperatingSystem.Windows, userHome: 'C:\\Users\\Me' - } as any, testConfigHelper); + } as any); linkHandler.processCwd = 'C:\\base'; assert.equal(linkHandler.preprocessPath('./src/file1'), 'C:\\base\\src\\file1'); @@ -257,7 +250,7 @@ suite('Workbench - TerminalLinkHandler', () => { const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { os: OperatingSystem.Windows, userHome: 'C:\\Users\\M e' - } as any, testConfigHelper); + } as any); linkHandler.processCwd = 'C:\\base dir'; assert.equal(linkHandler.preprocessPath('./src/file1'), 'C:\\base dir\\src\\file1'); @@ -271,7 +264,7 @@ suite('Workbench - TerminalLinkHandler', () => { const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { os: OperatingSystem.Linux, userHome: '/home/me' - } as any, testConfigHelper); + } as any); linkHandler.processCwd = '/base'; assert.equal(linkHandler.preprocessPath('./src/file1'), '/base/src/file1'); @@ -284,7 +277,7 @@ suite('Workbench - TerminalLinkHandler', () => { const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { os: OperatingSystem.Linux, userHome: '/home/me' - } as any, testConfigHelper); + } as any); assert.equal(linkHandler.preprocessPath('./src/file1'), null); assert.equal(linkHandler.preprocessPath('src/file2'), null); @@ -300,7 +293,7 @@ suite('Workbench - TerminalLinkHandler', () => { const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { os: OperatingSystem.Linux, userHome: '' - } as any, testConfigHelper); + } as any); linkHandler.onBeforeHandleLink(e => { if (e.link === 'https://www.microsoft.com') { intercepted = true; From d01deed96eaaad6b227714130135201b4881d9ac Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 15 May 2020 16:56:17 -0700 Subject: [PATCH 3/9] Remove unused interface --- .../terminal/test/browser/links/terminalLinkManager.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts index eda9209708a96..f5505864f146b 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts @@ -34,7 +34,6 @@ class TestTerminalLinkManager extends TerminalLinkManager { class TestXterm { public loadAddon() { } - public registerLinkMatcher() { } } class MockTerminalInstanceService implements ITerminalInstanceService { From 48ca7c9cd3d479adc033023c99b1bb3addbf1b93 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 19 May 2020 08:25:40 -0700 Subject: [PATCH 4/9] Correct unit test suite name --- .../terminal/test/browser/links/terminalLinkManager.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts index f5505864f146b..fe32ea42ca064 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts @@ -74,7 +74,7 @@ interface LinkFormatInfo { column?: string; } -suite('Workbench - TerminalLinkHandler', () => { +suite('Workbench - TerminalLinkManager', () => { let instantiationService: TestInstantiationService; setup(() => { From 643b98794cc25fe3c9a26d6e743c81898367d3e3 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 19 May 2020 09:00:57 -0700 Subject: [PATCH 5/9] Fix TerminalLinkManager tests --- .../browser/links/terminalLinkManager.test.ts | 179 ++---------------- 1 file changed, 14 insertions(+), 165 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts index fe32ea42ca064..7b9e636410bc7 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts @@ -5,8 +5,8 @@ import * as assert from 'assert'; import { OperatingSystem } from 'vs/base/common/platform'; -import { TerminalLinkManager, LineColumnInfo, XtermLinkMatcherHandler } from 'vs/workbench/contrib/terminal/browser/links/terminalLinkManager'; -import * as strings from 'vs/base/common/strings'; +import { TerminalLinkManager, XtermLinkMatcherHandler } from 'vs/workbench/contrib/terminal/browser/links/terminalLinkManager'; +import { Terminal as XtermTerminal } from 'xterm'; import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal'; import { Event } from 'vs/base/common/event'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; @@ -32,10 +32,6 @@ class TestTerminalLinkManager extends TerminalLinkManager { } } -class TestXterm { - public loadAddon() { } -} - class MockTerminalInstanceService implements ITerminalInstanceService { onRequestDefaultShellAndArgs?: Event | undefined; getDefaultShellAndArgs(): Promise<{ shell: string; args: string | string[] | undefined; }> { @@ -51,8 +47,9 @@ class MockTerminalInstanceService implements ITerminalInstanceService { getXtermUnicode11Constructor(): Promise { throw new Error('Method not implemented.'); } + // TODO: Remove this from the interface async getXtermWebLinksConstructor(): Promise { - return (await import('xterm-addon-web-links')).WebLinksAddon; + // return (await import('xterm-addon-web-links')).WebLinksAddon; } getXtermWebglConstructor(): Promise { throw new Error('Method not implemented.'); @@ -68,171 +65,23 @@ class MockTerminalInstanceService implements ITerminalInstanceService { } } -interface LinkFormatInfo { - urlFormat: string; - line?: string; - column?: string; -} - suite('Workbench - TerminalLinkManager', () => { let instantiationService: TestInstantiationService; - setup(() => { + setup(async () => { + const configurationService = new TestConfigurationService(); + await configurationService.setUserConfiguration('terminal', { integrated: { enableFileLinks: true } }); + instantiationService = new TestInstantiationService(); instantiationService.stub(IEnvironmentService, TestEnvironmentService); instantiationService.stub(IPathService, new TestPathService()); instantiationService.stub(ITerminalInstanceService, new MockTerminalInstanceService()); - instantiationService.stub(IConfigurationService, new TestConfigurationService()); - }); - - suite('localLinkRegex', () => { - test('Windows', () => { - const terminalLinkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm(), { - os: OperatingSystem.Windows, - userHome: '' - } as any); - function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) { - assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl); - assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl); - assert.equal(terminalLinkHandler.extractLinkUrl(`;${link};`), linkUrl); - assert.equal(terminalLinkHandler.extractLinkUrl(`(${link})`), linkUrl); - - if (lineNo) { - const lineColumnInfo: LineColumnInfo = terminalLinkHandler.extractLineColumnInfo(link); - assert.equal(lineColumnInfo.lineNumber, lineNo, `For link ${link}, expected line number ${lineNo}, actual ${lineColumnInfo.lineNumber}`); - - if (columnNo) { - assert.equal(lineColumnInfo.columnNumber, columnNo, `For link ${link}, expected column number ${columnNo}, actual ${lineColumnInfo.columnNumber}`); - } - } - } - - function generateAndTestLinks() { - const linkUrls = [ - 'c:\\foo', - '\\\\?\\c:\\foo', - 'c:/foo', - '.\\foo', - './foo', - '..\\foo', - '~\\foo', - '~/foo', - 'c:/a/long/path', - 'c:\\a\\long\\path', - 'c:\\mixed/slash\\path', - 'a/relative/path', - 'plain/path', - 'plain\\path' - ]; - - const supportedLinkFormats: LinkFormatInfo[] = [ - { urlFormat: '{0}' }, - { urlFormat: '{0} on line {1}', line: '5' }, - { urlFormat: '{0} on line {1}, column {2}', line: '5', column: '3' }, - { urlFormat: '{0}:line {1}', line: '5' }, - { urlFormat: '{0}:line {1}, column {2}', line: '5', column: '3' }, - { urlFormat: '{0}({1})', line: '5' }, - { urlFormat: '{0} ({1})', line: '5' }, - { urlFormat: '{0}({1},{2})', line: '5', column: '3' }, - { urlFormat: '{0} ({1},{2})', line: '5', column: '3' }, - { urlFormat: '{0}({1}, {2})', line: '5', column: '3' }, - { urlFormat: '{0} ({1}, {2})', line: '5', column: '3' }, - { urlFormat: '{0}:{1}', line: '5' }, - { urlFormat: '{0}:{1}:{2}', line: '5', column: '3' }, - { urlFormat: '{0}[{1}]', line: '5' }, - { urlFormat: '{0} [{1}]', line: '5' }, - { urlFormat: '{0}[{1},{2}]', line: '5', column: '3' }, - { urlFormat: '{0} [{1},{2}]', line: '5', column: '3' }, - { urlFormat: '{0}[{1}, {2}]', line: '5', column: '3' }, - { urlFormat: '{0} [{1}, {2}]', line: '5', column: '3' }, - { urlFormat: '"{0}",{1}', line: '5' } - ]; - - linkUrls.forEach(linkUrl => { - supportedLinkFormats.forEach(linkFormatInfo => { - testLink( - strings.format(linkFormatInfo.urlFormat, linkUrl, linkFormatInfo.line, linkFormatInfo.column), - linkUrl, - linkFormatInfo.line, - linkFormatInfo.column - ); - }); - }); - } - - generateAndTestLinks(); - }); - - test('Linux', () => { - const terminalLinkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm(), { - os: OperatingSystem.Linux, - userHome: '' - } as any); - function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) { - assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl); - assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl); - assert.equal(terminalLinkHandler.extractLinkUrl(`;${link};`), linkUrl); - assert.equal(terminalLinkHandler.extractLinkUrl(`(${link})`), linkUrl); - - if (lineNo) { - const lineColumnInfo: LineColumnInfo = terminalLinkHandler.extractLineColumnInfo(link); - assert.equal(lineColumnInfo.lineNumber, lineNo, `For link ${link}, expected line number ${lineNo}, actual ${lineColumnInfo.lineNumber}`); - - if (columnNo) { - assert.equal(lineColumnInfo.columnNumber, columnNo, `For link ${link}, expected column number ${columnNo}, actual ${lineColumnInfo.columnNumber}`); - } - } - } - - function generateAndTestLinks() { - const linkUrls = [ - '/foo', - '~/foo', - './foo', - '../foo', - '/a/long/path', - 'a/relative/path' - ]; - - const supportedLinkFormats: LinkFormatInfo[] = [ - { urlFormat: '{0}' }, - { urlFormat: '{0} on line {1}', line: '5' }, - { urlFormat: '{0} on line {1}, column {2}', line: '5', column: '3' }, - { urlFormat: '{0}:line {1}', line: '5' }, - { urlFormat: '{0}:line {1}, column {2}', line: '5', column: '3' }, - { urlFormat: '{0}({1})', line: '5' }, - { urlFormat: '{0} ({1})', line: '5' }, - { urlFormat: '{0}({1},{2})', line: '5', column: '3' }, - { urlFormat: '{0} ({1},{2})', line: '5', column: '3' }, - { urlFormat: '{0}:{1}', line: '5' }, - { urlFormat: '{0}:{1}:{2}', line: '5', column: '3' }, - { urlFormat: '{0}[{1}]', line: '5' }, - { urlFormat: '{0} [{1}]', line: '5' }, - { urlFormat: '{0}[{1},{2}]', line: '5', column: '3' }, - { urlFormat: '{0} [{1},{2}]', line: '5', column: '3' }, - { urlFormat: '"{0}",{1}', line: '5' } - ]; - - linkUrls.forEach(linkUrl => { - supportedLinkFormats.forEach(linkFormatInfo => { - // console.log('linkFormatInfo: ', linkFormatInfo); - testLink( - strings.format(linkFormatInfo.urlFormat, linkUrl, linkFormatInfo.line, linkFormatInfo.column), - linkUrl, - linkFormatInfo.line, - linkFormatInfo.column - ); - }); - }); - } - - generateAndTestLinks(); - }); + instantiationService.stub(IConfigurationService, configurationService); }); suite('preprocessPath', () => { test('Windows', () => { - const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { + const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new XtermTerminal() as any, { os: OperatingSystem.Windows, userHome: 'C:\\Users\\Me' } as any); @@ -246,7 +95,7 @@ suite('Workbench - TerminalLinkManager', () => { assert.equal(linkHandler.preprocessPath('\\\\?\\C:\\absolute\\path\\extended\\file6'), 'C:\\absolute\\path\\extended\\file6'); }); test('Windows - spaces', () => { - const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { + const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new XtermTerminal() as any, { os: OperatingSystem.Windows, userHome: 'C:\\Users\\M e' } as any); @@ -260,7 +109,7 @@ suite('Workbench - TerminalLinkManager', () => { }); test('Linux', () => { - const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { + const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new XtermTerminal() as any, { os: OperatingSystem.Linux, userHome: '/home/me' } as any); @@ -273,7 +122,7 @@ suite('Workbench - TerminalLinkManager', () => { }); test('No Workspace', () => { - const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { + const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new XtermTerminal() as any, { os: OperatingSystem.Linux, userHome: '/home/me' } as any); @@ -289,7 +138,7 @@ suite('Workbench - TerminalLinkManager', () => { const nullMouseEvent: any = Object.freeze({ preventDefault: () => { } }); test('should allow intercepting of links with onBeforeHandleLink', async () => { - const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new TestXterm() as any, { + const linkHandler: TestTerminalLinkManager = instantiationService.createInstance(TestTerminalLinkManager, new XtermTerminal() as any, { os: OperatingSystem.Linux, userHome: '' } as any); From b293be4c10bb2f3c6511ed37e57eb12105a48ecf Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 20 May 2020 06:38:50 -0700 Subject: [PATCH 6/9] Remove web links addon --- src/vs/workbench/contrib/terminal/browser/terminal.ts | 2 -- .../contrib/terminal/browser/terminalInstanceService.ts | 9 --------- .../terminal/electron-browser/terminalInstanceService.ts | 9 --------- .../test/browser/links/terminalLinkManager.test.ts | 4 ---- 4 files changed, 24 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.ts b/src/vs/workbench/contrib/terminal/browser/terminal.ts index d06119f17656b..f24715c58d048 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.ts @@ -6,7 +6,6 @@ import { Terminal as XTermTerminal } from 'xterm'; import { SearchAddon as XTermSearchAddon } from 'xterm-addon-search'; import { Unicode11Addon as XTermUnicode11Addon } from 'xterm-addon-unicode11'; -import { WebLinksAddon as XTermWebLinksAddon } from 'xterm-addon-web-links'; import { WebglAddon as XTermWebglAddon } from 'xterm-addon-webgl'; import { IWindowsShellHelper, ITerminalConfigHelper, ITerminalChildProcess, IShellLaunchConfig, IDefaultShellAndArgsRequest, ISpawnExtHostProcessRequest, IStartExtensionTerminalRequest, IAvailableShellsRequest, ITerminalProcessExtHostProxy, ICommandTracker, INavigationMode, TitleEventSource, ITerminalDimensions } from 'vs/workbench/contrib/terminal/common/terminal'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; @@ -33,7 +32,6 @@ export interface ITerminalInstanceService { getXtermConstructor(): Promise; getXtermSearchConstructor(): Promise; getXtermUnicode11Constructor(): Promise; - getXtermWebLinksConstructor(): Promise; getXtermWebglConstructor(): Promise; createWindowsShellHelper(shellProcessId: number, xterm: XTermTerminal): IWindowsShellHelper; createTerminalProcess(shellLaunchConfig: IShellLaunchConfig, cwd: string, cols: number, rows: number, env: IProcessEnvironment, windowsEnableConpty: boolean): ITerminalChildProcess; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstanceService.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstanceService.ts index e714542e72c30..52b03f24ccb01 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstanceService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstanceService.ts @@ -8,7 +8,6 @@ import { IWindowsShellHelper, ITerminalChildProcess, IDefaultShellAndArgsRequest import { Terminal as XTermTerminal } from 'xterm'; import { SearchAddon as XTermSearchAddon } from 'xterm-addon-search'; import { Unicode11Addon as XTermUnicode11Addon } from 'xterm-addon-unicode11'; -import { WebLinksAddon as XTermWebLinksAddon } from 'xterm-addon-web-links'; import { WebglAddon as XTermWebglAddon } from 'xterm-addon-webgl'; import { IProcessEnvironment } from 'vs/base/common/platform'; import { Emitter, Event } from 'vs/base/common/event'; @@ -17,7 +16,6 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; let Terminal: typeof XTermTerminal; let SearchAddon: typeof XTermSearchAddon; let Unicode11Addon: typeof XTermUnicode11Addon; -let WebLinksAddon: typeof XTermWebLinksAddon; let WebglAddon: typeof XTermWebglAddon; export class TerminalInstanceService implements ITerminalInstanceService { @@ -47,13 +45,6 @@ export class TerminalInstanceService implements ITerminalInstanceService { return Unicode11Addon; } - public async getXtermWebLinksConstructor(): Promise { - if (!WebLinksAddon) { - WebLinksAddon = (await import('xterm-addon-web-links')).WebLinksAddon; - } - return WebLinksAddon; - } - public async getXtermWebglConstructor(): Promise { if (!WebglAddon) { WebglAddon = (await import('xterm-addon-webgl')).WebglAddon; diff --git a/src/vs/workbench/contrib/terminal/electron-browser/terminalInstanceService.ts b/src/vs/workbench/contrib/terminal/electron-browser/terminalInstanceService.ts index 31034b572e2d8..2dbb6a0f2bec4 100644 --- a/src/vs/workbench/contrib/terminal/electron-browser/terminalInstanceService.ts +++ b/src/vs/workbench/contrib/terminal/electron-browser/terminalInstanceService.ts @@ -13,7 +13,6 @@ import { getSystemShell } from 'vs/workbench/contrib/terminal/node/terminal'; import { Terminal as XTermTerminal } from 'xterm'; import { SearchAddon as XTermSearchAddon } from 'xterm-addon-search'; import { Unicode11Addon as XTermUnicode11Addon } from 'xterm-addon-unicode11'; -import { WebLinksAddon as XTermWebLinksAddon } from 'xterm-addon-web-links'; import { WebglAddon as XTermWebglAddon } from 'xterm-addon-webgl'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { getDefaultShell, getDefaultShellArgs } from 'vs/workbench/contrib/terminal/common/terminalEnvironment'; @@ -27,7 +26,6 @@ import { ILogService } from 'vs/platform/log/common/log'; let Terminal: typeof XTermTerminal; let SearchAddon: typeof XTermSearchAddon; let Unicode11Addon: typeof XTermUnicode11Addon; -let WebLinksAddon: typeof XTermWebLinksAddon; let WebglAddon: typeof XTermWebglAddon; export class TerminalInstanceService implements ITerminalInstanceService { @@ -51,13 +49,6 @@ export class TerminalInstanceService implements ITerminalInstanceService { return Terminal; } - public async getXtermWebLinksConstructor(): Promise { - if (!WebLinksAddon) { - WebLinksAddon = (await import('xterm-addon-web-links')).WebLinksAddon; - } - return WebLinksAddon; - } - public async getXtermSearchConstructor(): Promise { if (!SearchAddon) { SearchAddon = (await import('xterm-addon-search')).SearchAddon; diff --git a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts index 7b9e636410bc7..c1a77fc1ed5c1 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/links/terminalLinkManager.test.ts @@ -47,10 +47,6 @@ class MockTerminalInstanceService implements ITerminalInstanceService { getXtermUnicode11Constructor(): Promise { throw new Error('Method not implemented.'); } - // TODO: Remove this from the interface - async getXtermWebLinksConstructor(): Promise { - // return (await import('xterm-addon-web-links')).WebLinksAddon; - } getXtermWebglConstructor(): Promise { throw new Error('Method not implemented.'); } From fdd075e9df49d2930d41f77347fdb2408c9fb89a Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 20 May 2020 06:54:45 -0700 Subject: [PATCH 7/9] Remove web links addon --- src/vs/code/browser/workbench/workbench-dev.html | 1 - src/vs/code/browser/workbench/workbench.html | 1 - 2 files changed, 2 deletions(-) diff --git a/src/vs/code/browser/workbench/workbench-dev.html b/src/vs/code/browser/workbench/workbench-dev.html index d7547c626a0fd..74ee36bca78d5 100644 --- a/src/vs/code/browser/workbench/workbench-dev.html +++ b/src/vs/code/browser/workbench/workbench-dev.html @@ -32,7 +32,6 @@ 'xterm': `${window.location.origin}/static/remote/web/node_modules/xterm/lib/xterm.js`, 'xterm-addon-search': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-search/lib/xterm-addon-search.js`, 'xterm-addon-unicode11': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`, - 'xterm-addon-web-links': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`, 'xterm-addon-webgl': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`, 'semver-umd': `${window.location.origin}/static/remote/web/node_modules/semver-umd/lib/semver-umd.js`, } diff --git a/src/vs/code/browser/workbench/workbench.html b/src/vs/code/browser/workbench/workbench.html index 0744523752817..1825bcffec659 100644 --- a/src/vs/code/browser/workbench/workbench.html +++ b/src/vs/code/browser/workbench/workbench.html @@ -36,7 +36,6 @@ 'xterm': `${window.location.origin}/static/node_modules/xterm/lib/xterm.js`, 'xterm-addon-search': `${window.location.origin}/static/node_modules/xterm-addon-search/lib/xterm-addon-search.js`, 'xterm-addon-unicode11': `${window.location.origin}/static/node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`, - 'xterm-addon-web-links': `${window.location.origin}/static/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`, 'xterm-addon-webgl': `${window.location.origin}/static/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`, 'semver-umd': `${window.location.origin}/static/node_modules/semver-umd/lib/semver-umd.js`, } From 94b5b5416a77c318f8dbf6e552b790eb57797fd6 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 20 May 2020 06:54:55 -0700 Subject: [PATCH 8/9] Update distro --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f2623317329af..76bd84097fd34 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", "version": "1.46.0", - "distro": "fee0da8fdb72dec6cd3a0b868bcc930928133a96", + "distro": "64a6a85a3b1af4e177210fa8c72b822322b129ab", "author": { "name": "Microsoft Corporation" }, From 1d4438027568f5cdb56cbd1bcd0d5f3b04e9514d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 20 May 2020 07:07:22 -0700 Subject: [PATCH 9/9] Remove xterm-addon-web-links package --- package.json | 1 - remote/package.json | 1 - remote/web/package.json | 1 - remote/web/yarn.lock | 5 ----- remote/yarn.lock | 5 ----- yarn.lock | 5 ----- 6 files changed, 18 deletions(-) diff --git a/package.json b/package.json index 76bd84097fd34..92cf868c6ab18 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "xterm": "4.7.0-beta.3", "xterm-addon-search": "0.7.0", "xterm-addon-unicode11": "0.2.0", - "xterm-addon-web-links": "0.4.0", "xterm-addon-webgl": "0.7.0", "yauzl": "^2.9.2", "yazl": "^2.4.3" diff --git a/remote/package.json b/remote/package.json index caffb3acbf04e..cba584d935d22 100644 --- a/remote/package.json +++ b/remote/package.json @@ -23,7 +23,6 @@ "xterm": "4.7.0-beta.3", "xterm-addon-search": "0.7.0", "xterm-addon-unicode11": "0.2.0", - "xterm-addon-web-links": "0.4.0", "xterm-addon-webgl": "0.7.0", "yauzl": "^2.9.2", "yazl": "^2.4.3" diff --git a/remote/web/package.json b/remote/web/package.json index a39a502ad736b..5a4ef27191041 100644 --- a/remote/web/package.json +++ b/remote/web/package.json @@ -8,7 +8,6 @@ "xterm": "4.7.0-beta.3", "xterm-addon-search": "0.7.0", "xterm-addon-unicode11": "0.2.0", - "xterm-addon-web-links": "0.4.0", "xterm-addon-webgl": "0.7.0" } } diff --git a/remote/web/yarn.lock b/remote/web/yarn.lock index 8029885a1bf0a..fa3681e1a9840 100644 --- a/remote/web/yarn.lock +++ b/remote/web/yarn.lock @@ -27,11 +27,6 @@ xterm-addon-unicode11@0.2.0: resolved "https://registry.yarnpkg.com/xterm-addon-unicode11/-/xterm-addon-unicode11-0.2.0.tgz#9ed0c482b353908bba27778893ca80823382737c" integrity sha512-rjFDItPc/IDoSiEnoDFwKroNwLD/7t9vYKENjrcKVZg5tgJuuUj8D4rZtP6iVCjSB1LTLYmUs4L/EmCqIyLR/Q== -xterm-addon-web-links@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.4.0.tgz#265cbf8221b9b315d0a748e1323bee331cd5da03" - integrity sha512-xv8GeiINmx0zENO9hf5k+5bnkaE8mRzF+OBAr9WeFq2eLaQSudioQSiT34M1ofKbzcdjSsKiZm19Rw3i4eXamg== - xterm-addon-webgl@0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.7.0.tgz#a13732ac937170e53ce02ec91963da042c80614b" diff --git a/remote/yarn.lock b/remote/yarn.lock index 2db867d364ce4..7ba3b88854fc8 100644 --- a/remote/yarn.lock +++ b/remote/yarn.lock @@ -414,11 +414,6 @@ xterm-addon-unicode11@0.2.0: resolved "https://registry.yarnpkg.com/xterm-addon-unicode11/-/xterm-addon-unicode11-0.2.0.tgz#9ed0c482b353908bba27778893ca80823382737c" integrity sha512-rjFDItPc/IDoSiEnoDFwKroNwLD/7t9vYKENjrcKVZg5tgJuuUj8D4rZtP6iVCjSB1LTLYmUs4L/EmCqIyLR/Q== -xterm-addon-web-links@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.4.0.tgz#265cbf8221b9b315d0a748e1323bee331cd5da03" - integrity sha512-xv8GeiINmx0zENO9hf5k+5bnkaE8mRzF+OBAr9WeFq2eLaQSudioQSiT34M1ofKbzcdjSsKiZm19Rw3i4eXamg== - xterm-addon-webgl@0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.7.0.tgz#a13732ac937170e53ce02ec91963da042c80614b" diff --git a/yarn.lock b/yarn.lock index d3532221baca1..0ed0c55f9e343 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10052,11 +10052,6 @@ xterm-addon-unicode11@0.2.0: resolved "https://registry.yarnpkg.com/xterm-addon-unicode11/-/xterm-addon-unicode11-0.2.0.tgz#9ed0c482b353908bba27778893ca80823382737c" integrity sha512-rjFDItPc/IDoSiEnoDFwKroNwLD/7t9vYKENjrcKVZg5tgJuuUj8D4rZtP6iVCjSB1LTLYmUs4L/EmCqIyLR/Q== -xterm-addon-web-links@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.4.0.tgz#265cbf8221b9b315d0a748e1323bee331cd5da03" - integrity sha512-xv8GeiINmx0zENO9hf5k+5bnkaE8mRzF+OBAr9WeFq2eLaQSudioQSiT34M1ofKbzcdjSsKiZm19Rw3i4eXamg== - xterm-addon-webgl@0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.7.0.tgz#a13732ac937170e53ce02ec91963da042c80614b"