提交 fe169ce4 编写于 作者: D Daniel Imms

Move terminalLinkHandler, electron-browser->browser

Part of #69115
上级 47977b99
......@@ -279,6 +279,7 @@
"./vs/workbench/contrib/surveys/electron-browser/nps.contribution.ts",
"./vs/workbench/contrib/terminal/browser/terminalFindWidget.ts",
"./vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts",
"./vs/workbench/contrib/terminal/browser/terminalQuickOpen.ts",
"./vs/workbench/contrib/terminal/browser/terminalTab.ts",
"./vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts",
......@@ -290,7 +291,6 @@
"./vs/workbench/contrib/terminal/electron-browser/terminalActions.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalInstance.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalLinkHandler.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalPanel.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalProcessManager.ts",
"./vs/workbench/contrib/terminal/node/terminal.ts",
......
......@@ -6,8 +6,7 @@
import * as nls from 'vs/nls';
import * as path from 'vs/base/common/path';
import * as platform from 'vs/base/common/platform';
import * as pfs from 'vs/base/node/pfs';
import { URI as Uri } from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/terminalWidgetManager';
......@@ -15,7 +14,53 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { ITerminalService } 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 { ILinkMatcherOptions } from 'vscode-xterm';
import { IFileService } from 'vs/platform/files/common/files';
// Since importing from vscode-xterm would be a layer breakage here the type is copied inline
// import { ILinkMatcherOptions } from 'vscode-xterm';
/**
* An object containing options for a link matcher.
*/
export interface ILinkMatcherOptions {
/**
* The index of the link from the regex.match(text) call. This defaults to 0
* (for regular expressions without capture groups).
*/
matchIndex?: number;
/**
* A callback that validates whether to create an individual link, pass
* whether the link is valid to the callback.
*/
validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void;
/**
* A callback that fires when the mouse hovers over a link for a moment.
*/
tooltipCallback?: (event: MouseEvent, uri: string) => boolean | void;
/**
* A callback that fires when the mouse leaves a link. Note that this can
* happen even when tooltipCallback hasn't fired for the link yet.
*/
leaveCallback?: (event: MouseEvent, uri: string) => boolean | void;
/**
* The priority of the link matcher, this defines the order in which the link
* matcher is evaluated relative to others, from highest to lowest. The
* default value is 0.
*/
priority?: number;
/**
* A callback that fires when the mousedown and click events occur that
* determines whether a link will be activated upon click. This enables
* only activating a link when a certain modifier is held down, if not the
* mouse event will continue propagation (eg. double click to select word).
*/
willLinkActivate?: (event: MouseEvent, uri: string) => boolean;
}
const pathPrefix = '(\\.\\.?|\\~)';
const pathSeparatorClause = '\\/';
......@@ -74,6 +119,7 @@ export class TerminalLinkHandler {
@IEditorService private readonly _editorService: IEditorService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ITerminalService private readonly _terminalService: ITerminalService,
@IFileService private readonly _fileService: IFileService
) {
const baseLocalLinkClause = _platform === platform.Platform.Windows ? winLocalLinkClause : unixLocalLinkClause;
// Append line and column number regex
......@@ -203,7 +249,7 @@ export class TerminalLinkHandler {
if (!normalizedUrl) {
return Promise.resolve(null);
}
const resource = Uri.file(normalizedUrl);
const resource = URI.file(normalizedUrl);
const lineColumnInfo: LineColumnInfo = this.extractLineColumnInfo(link);
const selection: ITextEditorSelection = {
startLineNumber: lineColumnInfo.lineNumber,
......@@ -223,7 +269,7 @@ export class TerminalLinkHandler {
}
private _handleHypertextLink(url: string): void {
const uri = Uri.parse(url);
const uri = URI.parse(url);
this._openerService.open(uri);
}
......@@ -288,7 +334,7 @@ export class TerminalLinkHandler {
}
// Ensure the file exists on disk, so an editor can be opened after clicking it
return pfs.fileExists(linkUrl).then(isFile => {
return this._fileService.existsFile(URI.file(linkUrl)).then(isFile => {
if (!isFile) {
return null;
}
......
......@@ -31,7 +31,7 @@ import { IShellLaunchConfig, ITerminalDimensions, ITerminalInstance, ITerminalPr
import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
import { TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminalCommands';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper';
import { TerminalLinkHandler } from 'vs/workbench/contrib/terminal/electron-browser/terminalLinkHandler';
import { TerminalLinkHandler } from 'vs/workbench/contrib/terminal/browser/terminalLinkHandler';
import { TerminalProcessManager } from 'vs/workbench/contrib/terminal/electron-browser/terminalProcessManager';
import { TerminalCommandTracker } from 'vs/workbench/contrib/terminal/node/terminalCommandTracker';
import { WindowsShellHelper } from 'vs/workbench/contrib/terminal/node/windowsShellHelper';
......
......@@ -5,7 +5,7 @@
import * as assert from 'assert';
import { Platform } from 'vs/base/common/platform';
import { TerminalLinkHandler, LineColumnInfo } from 'vs/workbench/contrib/terminal/electron-browser/terminalLinkHandler';
import { TerminalLinkHandler, LineColumnInfo } from 'vs/workbench/contrib/terminal/browser/terminalLinkHandler';
import * as strings from 'vs/base/common/strings';
import * as path from 'vs/base/common/path';
import * as sinon from 'sinon';
......@@ -39,7 +39,7 @@ interface LinkFormatInfo {
suite('Workbench - TerminalLinkHandler', () => {
suite('localLinkRegex', () => {
test('Windows', () => {
const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null!, null!, null!, null!);
const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null!, null!, null!, null!, null!);
function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) {
assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl);
assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl);
......@@ -111,7 +111,7 @@ suite('Workbench - TerminalLinkHandler', () => {
});
test('Linux', () => {
const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!);
const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!, null!);
function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) {
assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl);
assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl);
......@@ -175,7 +175,7 @@ suite('Workbench - TerminalLinkHandler', () => {
suite('preprocessPath', () => {
test('Windows', () => {
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null!, null!, null!, null!);
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null!, null!, null!, null!, null!);
linkHandler.processCwd = 'C:\\base';
let stub = sinon.stub(path, 'join', function (arg1: string, arg2: string) {
......@@ -188,7 +188,7 @@ suite('Workbench - TerminalLinkHandler', () => {
stub.restore();
});
test('Windows - spaces', () => {
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null!, null!, null!, null!);
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null!, null!, null!, null!, null!);
linkHandler.processCwd = 'C:\\base dir';
let stub = sinon.stub(path, 'join', function (arg1: string, arg2: string) {
......@@ -202,7 +202,7 @@ suite('Workbench - TerminalLinkHandler', () => {
});
test('Linux', () => {
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!);
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!, null!);
linkHandler.processCwd = '/base';
let stub = sinon.stub(path, 'join', function (arg1: string, arg2: string) {
......@@ -216,7 +216,7 @@ suite('Workbench - TerminalLinkHandler', () => {
});
test('No Workspace', () => {
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!);
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!, null!);
assert.equal(linkHandler.preprocessPath('./src/file1'), null);
assert.equal(linkHandler.preprocessPath('src/file2'), null);
......@@ -226,7 +226,7 @@ suite('Workbench - TerminalLinkHandler', () => {
test('gitDiffLinkRegex', () => {
// The platform is irrelevant because the links generated by Git are the same format regardless of platform
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!);
const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!, null!);
function assertAreGoodMatches(matches: RegExpMatchArray | null) {
if (matches) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册