mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
Merge pull request #186970 from microsoft/joh/payable-wildfowl
ESM - bring over more `importAMDNodeModule` usages
This commit is contained in:
commit
cd5dae5cf1
60
.eslintplugin/code-amd-node-module.ts
Normal file
60
.eslintplugin/code-amd-node-module.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as eslint from 'eslint';
|
||||
import { join } from 'path';
|
||||
|
||||
|
||||
export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
|
||||
|
||||
readonly meta: eslint.Rule.RuleMetaData = {
|
||||
messages: {
|
||||
amdX: 'Use `import type` for import declarations, use `amdX#importAMDNodeModule` for import expressions'
|
||||
}
|
||||
};
|
||||
|
||||
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
|
||||
|
||||
const modules = new Set<string>();
|
||||
|
||||
try {
|
||||
const { dependencies, optionalDependencies } = require(join(__dirname, '../package.json'));
|
||||
const all = Object.keys(dependencies).concat(Object.keys(optionalDependencies));
|
||||
for (const key of all) {
|
||||
modules.add(key);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
const checkImport = (node: any) => {
|
||||
|
||||
if (node.type !== 'Literal' || typeof node.value !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.parent.importKind === 'type') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!modules.has(node.value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'amdX'
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
['ImportExpression Literal']: checkImport,
|
||||
['ImportDeclaration Literal']: checkImport
|
||||
};
|
||||
}
|
||||
};
|
|
@ -194,6 +194,14 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"src/**/{common,browser}/**/*.ts"
|
||||
],
|
||||
"rules": {
|
||||
"local/code-amd-node-module": "warn"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"src/**/*.ts"
|
||||
|
|
|
@ -166,6 +166,9 @@ if (typeof globalThis.require === 'object') {
|
|||
}
|
||||
|
||||
/**
|
||||
* Utility for importing an AMD node module. This util supports AMD and ESM contexts and should be used while the ESM adoption
|
||||
* is on its way.
|
||||
*
|
||||
* e.g. pass in `vscode-textmate/release/main.js`
|
||||
*/
|
||||
export async function importAMDNodeModule<T>(nodeModuleName: string, pathInsideNodeModule: string, isBuilt?: boolean): Promise<T> {
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import * as filters from 'vs/base/common/filters';
|
||||
import { data } from 'vs/base/test/common/filters.perf.data';
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
|
||||
const patterns = ['cci', 'ida', 'pos', 'CCI', 'enbled', 'callback', 'gGame', 'cons', 'zyx', 'aBc'];
|
||||
|
||||
|
@ -15,7 +16,10 @@ function perfSuite(name: string, callback: (this: Mocha.Suite) => void) {
|
|||
}
|
||||
}
|
||||
|
||||
perfSuite('Performance - fuzzyMatch', function () {
|
||||
perfSuite('Performance - fuzzyMatch', async function () {
|
||||
|
||||
const uri = FileAccess.asBrowserUri('vs/base/test/common/filters.perf.data').toString(true);
|
||||
const { data } = await importAMDNodeModule<typeof import('vs/base/test/common/filters.perf.data')>(uri, '');
|
||||
|
||||
// suiteSetup(() => console.profile());
|
||||
// suiteTeardown(() => console.profileEnd());
|
||||
|
@ -47,7 +51,10 @@ perfSuite('Performance - fuzzyMatch', function () {
|
|||
});
|
||||
|
||||
|
||||
perfSuite('Performance - IFilter', function () {
|
||||
perfSuite('Performance - IFilter', async function () {
|
||||
|
||||
const uri = FileAccess.asBrowserUri('vs/base/test/common/filters.perf.data').toString(true);
|
||||
const { data } = await importAMDNodeModule<typeof import('vs/base/test/common/filters.perf.data')>(uri, '');
|
||||
|
||||
function perfTest(name: string, match: filters.IFilter) {
|
||||
test(name, () => {
|
||||
|
|
|
@ -9,6 +9,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
|||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { getTelemetryLevel } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { AssignmentFilterProvider, ASSIGNMENT_REFETCH_INTERVAL, ASSIGNMENT_STORAGE_KEY, IAssignmentService, TargetPopulation } from 'vs/platform/assignment/common/assignment';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
export abstract class BaseAssignmentService implements IAssignmentService {
|
||||
_serviceBrand: undefined;
|
||||
|
@ -85,7 +86,7 @@ export abstract class BaseAssignmentService implements IAssignmentService {
|
|||
);
|
||||
|
||||
const tasConfig = this.productService.tasConfig!;
|
||||
const tasClient = new (await import('tas-client-umd')).ExperimentationService({
|
||||
const tasClient = new (await importAMDNodeModule<typeof import('tas-client-umd')>('tas-client-umd', 'lib/tas-client-umd.js')).ExperimentationService({
|
||||
filterProviders: [filterProvider],
|
||||
telemetry: this.telemetry,
|
||||
storageKey: ASSIGNMENT_STORAGE_KEY,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import type { IExtendedConfiguration, IExtendedTelemetryItem, ITelemetryItem, ITelemetryUnloadState } from '@microsoft/1ds-core-js';
|
||||
import type { IChannelConfiguration, IXHROverride, PostChannel } from '@microsoft/1ds-post-js';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { ITelemetryAppender, validateTelemetryData } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
|
@ -21,8 +22,8 @@ const endpointUrl = 'https://mobile.events.data.microsoft.com/OneCollector/1.0';
|
|||
const endpointHealthUrl = 'https://mobile.events.data.microsoft.com/ping';
|
||||
|
||||
async function getClient(instrumentationKey: string, addInternalFlag?: boolean, xhrOverride?: IXHROverride): Promise<IAppInsightsCore> {
|
||||
const oneDs = await import('@microsoft/1ds-core-js');
|
||||
const postPlugin = await import('@microsoft/1ds-post-js');
|
||||
const oneDs = await importAMDNodeModule<typeof import('@microsoft/1ds-core-js')>('@microsoft/1ds-core-js', 'dist/ms.core.js');
|
||||
const postPlugin = await importAMDNodeModule<typeof import('@microsoft/1ds-post-js')>('@microsoft/1ds-post-js', 'dist/ms.post.js');
|
||||
const appInsightsCore = new oneDs.AppInsightsCore();
|
||||
const collectorChannelPlugin: PostChannel = new postPlugin.PostChannel();
|
||||
// Configure the app insights core to send to collector++ and disable logging of debug info
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { ITelemetryItem, ITelemetryUnloadState } from '@microsoft/1ds-core-js';
|
||||
import type { ITelemetryItem, ITelemetryUnloadState } from '@microsoft/1ds-core-js';
|
||||
import * as assert from 'assert';
|
||||
import { OneDataSystemWebAppender } from 'vs/platform/telemetry/browser/1dsAppender';
|
||||
import { IAppInsightsCore } from 'vs/platform/telemetry/common/1dsAppender';
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Emitter } from 'vs/base/common/event';
|
|||
import { IPartialCommandDetectionCapability, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
// Importing types is safe in any layer
|
||||
// eslint-disable-next-line local/code-import-patterns
|
||||
import { IMarker, Terminal } from 'xterm-headless';
|
||||
import type { IMarker, Terminal } from 'xterm-headless';
|
||||
|
||||
const enum Constants {
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration';
|
||||
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
|
||||
|
@ -22,7 +22,6 @@ import { IInstantiationService, createDecorator } from 'vs/platform/instantiatio
|
|||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { SelectionClipboardContributionID } from 'vs/workbench/contrib/codeEditor/browser/selectionClipboard';
|
||||
import { getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
|
||||
import { IDisposable } from 'xterm';
|
||||
|
||||
const enum DIMENSION_DEFAULT {
|
||||
WIDTH = .6,
|
||||
|
|
|
@ -8,7 +8,7 @@ import * as Async from 'vs/base/common/async';
|
|||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { isUNC } from 'vs/base/common/extpath';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { LinkedMap, Touch } from 'vs/base/common/map';
|
||||
import * as Objects from 'vs/base/common/objects';
|
||||
import * as path from 'vs/base/common/path';
|
||||
|
@ -49,7 +49,6 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
|
|||
import { IOutputService } from 'vs/workbench/services/output/common/output';
|
||||
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite';
|
||||
import { IPathService } from 'vs/workbench/services/path/common/pathService';
|
||||
import { IDisposable } from 'xterm';
|
||||
|
||||
interface ITerminalData {
|
||||
terminal: ITerminalInstance;
|
||||
|
|
|
@ -25,7 +25,7 @@ import { XtermTerminal } from 'vs/workbench/contrib/terminal/browser/xterm/xterm
|
|||
import { IRegisterContributedProfileArgs, IRemoteTerminalAttachTarget, IStartExtensionTerminalRequest, ITerminalConfigHelper, ITerminalFont, ITerminalProcessExtHostProxy } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { ISimpleSelectedSuggestion } from 'vs/workbench/services/suggest/browser/simpleSuggestWidget';
|
||||
import { IMarker, Terminal as RawXtermTerminal } from 'xterm';
|
||||
import type { IMarker, Terminal as RawXtermTerminal } from 'xterm';
|
||||
|
||||
export const ITerminalService = createDecorator<ITerminalService>('terminalService');
|
||||
export const ITerminalEditorService = createDecorator<ITerminalEditorService>('terminalEditorService');
|
||||
|
|
|
@ -85,6 +85,7 @@ import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
|||
import { IWorkbenchLayoutService, Position } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { IPathService } from 'vs/workbench/services/path/common/pathService';
|
||||
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { ISimpleSelectedSuggestion } from 'vs/workbench/services/suggest/browser/simpleSuggestWidget';
|
||||
import type { IMarker, Terminal as XTermTerminal } from 'xterm';
|
||||
|
||||
|
@ -684,7 +685,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
return xtermConstructor;
|
||||
}
|
||||
xtermConstructor = Promises.withAsyncBody<typeof XTermTerminal>(async (resolve) => {
|
||||
const Terminal = (await import('xterm')).Terminal;
|
||||
const Terminal = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
// Localize strings
|
||||
Terminal.strings.promptLabel = nls.localize('terminal.integrated.a11yPromptLabel', 'Terminal input');
|
||||
Terminal.strings.tooMuchOutput = keybinding ? nls.localize('terminal.integrated.useAccessibleBuffer', 'Use the accessible buffer {0} to manually review output', keybinding.getLabel()) : nls.localize('terminal.integrated.useAccessibleBufferNoKb', 'Use the Terminal: Focus Accessible Buffer command to manually review output');
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
|
||||
export async function writeP(terminal: Terminal, data: string): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
|
@ -16,4 +16,3 @@ export async function writeP(terminal: Terminal, data: string): Promise<void> {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import { terminalDecorationError, terminalDecorationIncomplete, terminalDecorati
|
|||
import { DecorationSelector, TerminalDecorationHoverManager, updateLayout } from 'vs/workbench/contrib/terminal/browser/xterm/decorationStyles';
|
||||
import { TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR, TERMINAL_COMMAND_DECORATION_ERROR_BACKGROUND_COLOR, TERMINAL_COMMAND_DECORATION_SUCCESS_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
|
||||
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { IDecoration, ITerminalAddon, Terminal } from 'xterm';
|
||||
import type { IDecoration, ITerminalAddon, Terminal } from 'xterm';
|
||||
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag
|
|||
import { activeContrastBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { ISuggestController } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { TerminalStorageKeys } from 'vs/workbench/contrib/terminal/common/terminalStorageKeys';
|
||||
import { ITerminalAddon, Terminal } from 'xterm';
|
||||
import type { ITerminalAddon, Terminal } from 'xterm';
|
||||
import { getListStyles } from 'vs/platform/theme/browser/defaultStyles';
|
||||
|
||||
const enum ShellIntegrationOscPs {
|
||||
|
|
|
@ -35,6 +35,7 @@ import { DecorationAddon } from 'vs/workbench/contrib/terminal/browser/xterm/dec
|
|||
import { ITerminalCapabilityStore, ITerminalCommand, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { SuggestAddon } from 'vs/workbench/contrib/terminal/browser/xterm/suggestAddon';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
|
||||
|
@ -682,7 +683,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
|
|||
|
||||
protected async _getCanvasAddonConstructor(): Promise<typeof CanvasAddonType> {
|
||||
if (!CanvasAddon) {
|
||||
CanvasAddon = (await import('xterm-addon-canvas')).CanvasAddon;
|
||||
CanvasAddon = (await importAMDNodeModule<typeof import('xterm-addon-canvas')>('xterm-addon-canvas', 'lib/xterm-addon-canvas.js')).CanvasAddon;
|
||||
}
|
||||
return CanvasAddon;
|
||||
}
|
||||
|
@ -706,35 +707,35 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
|
|||
|
||||
protected async _getImageAddonConstructor(): Promise<typeof ImageAddonType> {
|
||||
if (!ImageAddon) {
|
||||
ImageAddon = (await import('xterm-addon-image')).ImageAddon;
|
||||
ImageAddon = (await importAMDNodeModule<typeof import('xterm-addon-image')>('xterm-addon-image', 'lib/xterm-addon-image.js')).ImageAddon;
|
||||
}
|
||||
return ImageAddon;
|
||||
}
|
||||
|
||||
protected async _getSearchAddonConstructor(): Promise<typeof SearchAddonType> {
|
||||
if (!SearchAddon) {
|
||||
SearchAddon = (await import('xterm-addon-search')).SearchAddon;
|
||||
SearchAddon = (await importAMDNodeModule<typeof import('xterm-addon-search')>('xterm-addon-search', 'lib/xterm-addon-search.js')).SearchAddon;
|
||||
}
|
||||
return SearchAddon;
|
||||
}
|
||||
|
||||
protected async _getUnicode11Constructor(): Promise<typeof Unicode11AddonType> {
|
||||
if (!Unicode11Addon) {
|
||||
Unicode11Addon = (await import('xterm-addon-unicode11')).Unicode11Addon;
|
||||
Unicode11Addon = (await importAMDNodeModule<typeof import('xterm-addon-unicode11')>('xterm-addon-unicode11', 'lib/xterm-addon-unicode11.js')).Unicode11Addon;
|
||||
}
|
||||
return Unicode11Addon;
|
||||
}
|
||||
|
||||
protected async _getWebglAddonConstructor(): Promise<typeof WebglAddonType> {
|
||||
if (!WebglAddon) {
|
||||
WebglAddon = (await import('xterm-addon-webgl')).WebglAddon;
|
||||
WebglAddon = (await importAMDNodeModule<typeof import('xterm-addon-webgl')>('xterm-addon-webgl', 'lib/xterm-addon-webgl.js')).WebglAddon;
|
||||
}
|
||||
return WebglAddon;
|
||||
}
|
||||
|
||||
protected async _getSerializeAddonConstructor(): Promise<typeof SerializeAddonType> {
|
||||
if (!SerializeAddon) {
|
||||
SerializeAddon = (await import('xterm-addon-serialize')).SerializeAddon;
|
||||
SerializeAddon = (await importAMDNodeModule<typeof import('xterm-addon-serialize')>('xterm-addon-serialize', 'lib/xterm-addon-serialize.js')).SerializeAddon;
|
||||
}
|
||||
return SerializeAddon;
|
||||
}
|
||||
|
|
|
@ -4,13 +4,14 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { deepStrictEqual, ok } from 'assert';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
import { CommandDetectionCapability } from 'vs/platform/terminal/common/capabilities/commandDetectionCapability';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ITerminalCommand } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { IContextMenuDelegate } from 'vs/base/browser/contextmenu';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { writeP } from 'vs/workbench/contrib/terminal/browser/terminalTestHelpers';
|
||||
|
||||
type TestTerminalCommandMatch = Pick<ITerminalCommand, 'command' | 'cwd' | 'exitCode'> & { marker: { line: number } };
|
||||
|
@ -54,8 +55,10 @@ suite('CommandDetectionCapability', () => {
|
|||
capability.handleCommandFinished(exitCode);
|
||||
}
|
||||
|
||||
setup(() => {
|
||||
xterm = new Terminal({ allowProposedApi: true, cols: 80 });
|
||||
setup(async () => {
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
|
||||
xterm = new TerminalCtor({ allowProposedApi: true, cols: 80 });
|
||||
const instantiationService = new TestInstantiationService();
|
||||
instantiationService.stub(IContextMenuService, { showContextMenu(delegate: IContextMenuDelegate): void { } } as Partial<IContextMenuService>);
|
||||
capability = new TestCommandDetectionCapability(xterm, new NullLogService());
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
|
||||
import { deepStrictEqual } from 'assert';
|
||||
import { PartialCommandDetectionCapability } from 'vs/platform/terminal/common/capabilities/partialCommandDetectionCapability';
|
||||
import { IMarker, Terminal } from 'xterm';
|
||||
import type { IMarker, Terminal } from 'xterm';
|
||||
import { IXtermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { writeP } from 'vs/workbench/contrib/terminal/browser/terminalTestHelpers';
|
||||
|
||||
interface TestTerminal extends Terminal {
|
||||
|
@ -23,8 +24,10 @@ suite('PartialCommandDetectionCapability', () => {
|
|||
deepStrictEqual(addEvents.map(e => e.line), expectedLines);
|
||||
}
|
||||
|
||||
setup(() => {
|
||||
xterm = new Terminal({ allowProposedApi: true, cols: 80 }) as TestTerminal;
|
||||
setup(async () => {
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
|
||||
xterm = new TerminalCtor({ allowProposedApi: true, cols: 80 }) as TestTerminal;
|
||||
capability = new PartialCommandDetectionCapability(xterm);
|
||||
addEvents = [];
|
||||
capability.onCommandFinished(e => addEvents.push(e));
|
||||
|
|
|
@ -10,7 +10,7 @@ import { ILogService, NullLogService } from 'vs/platform/log/common/log';
|
|||
import { DecorationAddon } from 'vs/workbench/contrib/terminal/browser/xterm/decorationAddon';
|
||||
import { TerminalCapabilityStore } from 'vs/platform/terminal/common/capabilities/terminalCapabilityStore';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IDecoration, IDecorationOptions, Terminal } from 'xterm';
|
||||
import type { IDecoration, IDecorationOptions } from 'xterm';
|
||||
import { ITerminalCommand, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { CommandDetectionCapability } from 'vs/platform/terminal/common/capabilities/commandDetectionCapability';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
|
@ -19,18 +19,21 @@ import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService
|
|||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { TestLifecycleService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
class TestTerminal extends Terminal {
|
||||
override registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined {
|
||||
if (decorationOptions.marker.isDisposed) {
|
||||
return undefined;
|
||||
suite('DecorationAddon', async () => {
|
||||
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
class TestTerminal extends TerminalCtor {
|
||||
override registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined {
|
||||
if (decorationOptions.marker.isDisposed) {
|
||||
return undefined;
|
||||
}
|
||||
const element = document.createElement('div');
|
||||
return { marker: decorationOptions.marker, element, onDispose: () => { }, isDisposed: false, dispose: () => { }, onRender: (element: HTMLElement) => { return element; } } as unknown as IDecoration;
|
||||
}
|
||||
const element = document.createElement('div');
|
||||
return { marker: decorationOptions.marker, element, onDispose: () => { }, isDisposed: false, dispose: () => { }, onRender: (element: HTMLElement) => { return element; } } as unknown as IDecoration;
|
||||
}
|
||||
}
|
||||
|
||||
suite('DecorationAddon', () => {
|
||||
let decorationAddon: DecorationAddon;
|
||||
let xterm: TestTerminal;
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
import { LineDataEventAddon } from 'vs/workbench/contrib/terminal/browser/xterm/lineDataEventAddon';
|
||||
import { OperatingSystem } from 'vs/base/common/platform';
|
||||
import { deepStrictEqual } from 'assert';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { writeP } from 'vs/workbench/contrib/terminal/browser/terminalTestHelpers';
|
||||
|
||||
suite('LineDataEventAddon', () => {
|
||||
|
@ -16,8 +17,9 @@ suite('LineDataEventAddon', () => {
|
|||
suite('onLineData', () => {
|
||||
let events: string[];
|
||||
|
||||
setup(() => {
|
||||
xterm = new Terminal({ allowProposedApi: true, cols: 4 });
|
||||
setup(async () => {
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = new TerminalCtor({ allowProposedApi: true, cols: 4 });
|
||||
lineDataEventAddon = new LineDataEventAddon();
|
||||
xterm.loadAddon(lineDataEventAddon);
|
||||
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
import { strictEqual, deepStrictEqual, deepEqual } from 'assert';
|
||||
import * as sinon from 'sinon';
|
||||
import { parseKeyValueAssignment, parseMarkSequence, deserializeMessage, ShellIntegrationAddon } from 'vs/platform/terminal/common/xterm/shellIntegrationAddon';
|
||||
import { ITerminalCapabilityStore, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { writeP } from 'vs/workbench/contrib/terminal/browser/terminalTestHelpers';
|
||||
|
||||
class TestShellIntegrationAddon extends ShellIntegrationAddon {
|
||||
|
@ -29,8 +30,10 @@ suite('ShellIntegrationAddon', () => {
|
|||
let shellIntegrationAddon: TestShellIntegrationAddon;
|
||||
let capabilities: ITerminalCapabilityStore;
|
||||
|
||||
setup(() => {
|
||||
xterm = new Terminal({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
setup(async () => {
|
||||
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = new TerminalCtor({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
shellIntegrationAddon = new TestShellIntegrationAddon('', true, undefined, new NullLogService());
|
||||
xterm.loadAddon(shellIntegrationAddon);
|
||||
capabilities = shellIntegrationAddon.capabilities;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IEvent, Terminal } from 'xterm';
|
||||
import type { IEvent, Terminal } from 'xterm';
|
||||
import { XtermTerminal } from 'vs/workbench/contrib/terminal/browser/xterm/xtermTerminal';
|
||||
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
|
@ -18,7 +18,7 @@ import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
|||
import { Emitter } from 'vs/base/common/event';
|
||||
import { TERMINAL_BACKGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR, TERMINAL_SELECTION_FOREGROUND_COLOR, TERMINAL_INACTIVE_SELECTION_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
|
||||
import { PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
|
||||
import { WebglAddon } from 'xterm-addon-webgl';
|
||||
import type { WebglAddon } from 'xterm-addon-webgl';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
|
@ -28,6 +28,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
|
|||
import { ContextMenuService } from 'vs/platform/contextview/browser/contextMenuService';
|
||||
import { TestLifecycleService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import { Color, RGBA } from 'vs/base/common/color';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
@ -97,8 +98,9 @@ suite('XtermTerminal', () => {
|
|||
let viewDescriptorService: TestViewDescriptorService;
|
||||
let xterm: TestXtermTerminal;
|
||||
let configHelper: TerminalConfigHelper;
|
||||
let XTermBaseCtor: typeof Terminal;
|
||||
|
||||
setup(() => {
|
||||
setup(async () => {
|
||||
configurationService = new TestConfigurationService({
|
||||
editor: {
|
||||
fastScrollSensitivity: 2,
|
||||
|
@ -122,7 +124,9 @@ suite('XtermTerminal', () => {
|
|||
instantiationService.stub(IContextKeyService, new MockContextKeyService());
|
||||
|
||||
configHelper = instantiationService.createInstance(TerminalConfigHelper);
|
||||
xterm = instantiationService.createInstance(TestXtermTerminal, Terminal, configHelper, 80, 30, { getBackgroundColor: () => undefined }, new TerminalCapabilityStore(), '', new MockContextKeyService().createKey('', true)!, true);
|
||||
XTermBaseCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
|
||||
xterm = instantiationService.createInstance(TestXtermTerminal, XTermBaseCtor, configHelper, 80, 30, { getBackgroundColor: () => undefined }, new TerminalCapabilityStore(), '', new MockContextKeyService().createKey('', true)!, true);
|
||||
|
||||
TestWebglAddon.shouldThrow = false;
|
||||
TestWebglAddon.isEnabled = false;
|
||||
|
@ -139,7 +143,7 @@ suite('XtermTerminal', () => {
|
|||
[PANEL_BACKGROUND]: '#ff0000',
|
||||
[SIDE_BAR_BACKGROUND]: '#00ff00'
|
||||
}));
|
||||
xterm = instantiationService.createInstance(XtermTerminal, Terminal, configHelper, 80, 30, { getBackgroundColor: () => new Color(new RGBA(255, 0, 0)) }, new TerminalCapabilityStore(), '', new MockContextKeyService().createKey('', true)!, true);
|
||||
xterm = instantiationService.createInstance(XtermTerminal, XTermBaseCtor, configHelper, 80, 30, { getBackgroundColor: () => new Color(new RGBA(255, 0, 0)) }, new TerminalCapabilityStore(), '', new MockContextKeyService().createKey('', true)!, true);
|
||||
strictEqual(xterm.raw.options.theme?.background, '#ff0000');
|
||||
});
|
||||
test('should react to and apply theme changes', () => {
|
||||
|
@ -168,7 +172,7 @@ suite('XtermTerminal', () => {
|
|||
'terminal.ansiBrightCyan': '#150000',
|
||||
'terminal.ansiBrightWhite': '#160000',
|
||||
}));
|
||||
xterm = instantiationService.createInstance(XtermTerminal, Terminal, configHelper, 80, 30, { getBackgroundColor: () => undefined }, new TerminalCapabilityStore(), '', new MockContextKeyService().createKey('', true)!, true);
|
||||
xterm = instantiationService.createInstance(XtermTerminal, XTermBaseCtor, configHelper, 80, 30, { getBackgroundColor: () => undefined }, new TerminalCapabilityStore(), '', new MockContextKeyService().createKey('', true)!, true);
|
||||
deepStrictEqual(xterm.raw.options.theme, {
|
||||
background: undefined,
|
||||
foreground: '#000200',
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ITerminalLogService, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
|
||||
import { IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { IMarker, Terminal } from 'xterm';
|
||||
import type { IMarker, Terminal } from 'xterm';
|
||||
|
||||
export class BufferContentTracker {
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@ import { ITerminalProcessManager, TerminalCommandId } from 'vs/workbench/contrib
|
|||
import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
|
||||
import { TerminalAccessibleContentProvider } from 'vs/workbench/contrib/terminalContrib/accessibility/browser/terminalAccessibilityHelp';
|
||||
import { AccessibleBufferWidget, NavigationType } from 'vs/workbench/contrib/terminalContrib/accessibility/browser/terminalAccessibleBuffer';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
|
||||
class AccessibleBufferContribution extends DisposableStore implements ITerminalContribution {
|
||||
static readonly ID = 'terminal.accessible-buffer';
|
||||
|
|
|
@ -13,7 +13,7 @@ import { ShellIntegrationStatus, WindowsShellType } from 'vs/platform/terminal/c
|
|||
import { AccessibleViewType, IAccessibleContentProvider, IAccessibleViewOptions } from 'vs/workbench/contrib/accessibility/browser/accessibleView';
|
||||
import { ITerminalInstance, IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
|
||||
export const enum ClassName {
|
||||
AccessibleBuffer = 'terminal-accessibility-help',
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
|
@ -26,7 +27,7 @@ import { BufferContentTracker } from 'vs/workbench/contrib/terminalContrib/acces
|
|||
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { TestLifecycleService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestLoggerService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
|
||||
const defaultTerminalConfig: Partial<ITerminalConfiguration> = {
|
||||
fontFamily: 'monospace',
|
||||
|
@ -49,7 +50,7 @@ suite('Buffer Content Tracker', () => {
|
|||
let bufferTracker: BufferContentTracker;
|
||||
const prompt = 'vscode-git:(prompt/more-tests)';
|
||||
const promptPlusData = 'vscode-git:(prompt/more-tests) ' + 'some data';
|
||||
setup(() => {
|
||||
setup(async () => {
|
||||
configurationService = new TestConfigurationService({ terminal: { integrated: defaultTerminalConfig } });
|
||||
instantiationService = new TestInstantiationService();
|
||||
themeService = new TestThemeService();
|
||||
|
@ -66,7 +67,8 @@ suite('Buffer Content Tracker', () => {
|
|||
if (!isWindows) {
|
||||
capabilities.add(TerminalCapability.NaiveCwdDetection, null!);
|
||||
}
|
||||
xterm = instantiationService.createInstance(XtermTerminal, Terminal, configHelper, 80, 30, { getBackgroundColor: () => undefined }, capabilities, '', new MockContextKeyService().createKey('', true)!, true);
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = instantiationService.createInstance(XtermTerminal, TerminalCtor, configHelper, 80, 30, { getBackgroundColor: () => undefined }, capabilities, '', new MockContextKeyService().createKey('', true)!, true);
|
||||
const container = document.createElement('div');
|
||||
xterm.raw.open(container);
|
||||
configurationService = new TestConfigurationService({ terminal: { integrated: { tabs: { separator: ' - ', title: '${cwd}', description: '${cwd}' } } } });
|
||||
|
@ -137,4 +139,3 @@ async function writeAndAssertBufferState(data: string, rows: number, terminal: T
|
|||
assert.strictEqual(bufferTracker.lines.length, rows);
|
||||
assert.deepStrictEqual(bufferTracker.lines, content.split('\r\n'));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/wid
|
|||
import { ITerminalProcessManager, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
|
||||
import { TerminalFindWidget } from 'vs/workbench/contrib/terminalContrib/find/browser/terminalFindWidget';
|
||||
import { Terminal as RawXtermTerminal } from 'xterm';
|
||||
import type { Terminal as RawXtermTerminal } from 'xterm';
|
||||
|
||||
class TerminalFindContribution extends Disposable implements ITerminalContribution {
|
||||
static readonly ID = 'terminal.find';
|
||||
|
|
|
@ -12,7 +12,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
|
|||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { ISearchOptions } from 'xterm-addon-search';
|
||||
import type { ISearchOptions } from 'xterm-addon-search';
|
||||
|
||||
export class TerminalFindWidget extends SimpleFindWidget {
|
||||
private _findInputFocused: IContextKey<boolean>;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IBufferLine, IBufferRange, Terminal } from 'xterm';
|
||||
import type { IBufferLine, IBufferRange, Terminal } from 'xterm';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IHoverAction } from 'vs/workbench/services/hover/browser/hover';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
|
|
@ -21,7 +21,7 @@ import { IDetectedLinks, TerminalLinkManager } from 'vs/workbench/contrib/termin
|
|||
import { TerminalLinkProviderService } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkProviderService';
|
||||
import { TerminalLinkQuickpick } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkQuickpick';
|
||||
import { TerminalLinkResolver } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkResolver';
|
||||
import { Terminal as RawXtermTerminal } from 'xterm';
|
||||
import type { Terminal as RawXtermTerminal } from 'xterm';
|
||||
|
||||
registerSingleton(ITerminalLinkProviderService, TerminalLinkProviderService, InstantiationType.Delayed);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { ITerminalLinkDetector, ITerminalSimpleLink, OmitFirstArg } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
|
||||
import { convertLinkRangeToBuffer, getXtermLineContent } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkHelpers';
|
||||
import { ITerminalExternalLinkProvider } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { IBufferLine, Terminal } from 'xterm';
|
||||
import type { IBufferLine, Terminal } from 'xterm';
|
||||
|
||||
export class TerminalExternalLinkDetector implements ITerminalLinkDetector {
|
||||
readonly maxLinkLength = 2000;
|
||||
|
|
|
@ -10,7 +10,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||
import { ITerminalLinkDetector, ITerminalSimpleLink, TerminalBuiltinLinkType, TerminalLinkType } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
|
||||
import { TerminalLink } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLink';
|
||||
import { XtermLinkMatcherHandler } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkManager';
|
||||
import { IBufferLine, ILink, ILinkProvider, IViewportRange } from 'xterm';
|
||||
import type { IBufferLine, ILink, ILinkProvider, IViewportRange } from 'xterm';
|
||||
|
||||
export interface IActivateLinkEvent {
|
||||
link: ITerminalSimpleLink;
|
||||
|
|
|
@ -9,7 +9,7 @@ import { localize } from 'vs/nls';
|
|||
import { QuickPickItem, IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { IDetectedLinks } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkManager';
|
||||
import { TerminalLinkQuickPickEvent } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { ILink } from 'xterm';
|
||||
import type { ILink } from 'xterm';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
|
||||
export class TerminalLinkQuickpick extends DisposableStore {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
|
|||
import { ITerminalLinkDetector, ITerminalLinkResolver, ITerminalSimpleLink, ResolvedLink, TerminalBuiltinLinkType } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
|
||||
import { convertLinkRangeToBuffer, getXtermLineContent, getXtermRangesByAttr, osPathModule, updateLinkWithRelativeCwd } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkHelpers';
|
||||
import { ITerminalCapabilityStore, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { IBufferLine, IBufferRange, Terminal } from 'xterm';
|
||||
import type { IBufferLine, IBufferRange, Terminal } from 'xterm';
|
||||
import { ITerminalProcessManager } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { detectLinks } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing';
|
||||
import { ITerminalBackend, ITerminalLogService } from 'vs/platform/terminal/common/terminal';
|
||||
|
|
|
@ -8,7 +8,7 @@ import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'
|
|||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { ITerminalLinkDetector, ITerminalLinkResolver, ITerminalSimpleLink, TerminalBuiltinLinkType } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
|
||||
import { convertLinkRangeToBuffer, getXtermLineContent } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkHelpers';
|
||||
import { IBufferLine, Terminal } from 'xterm';
|
||||
import type { IBufferLine, Terminal } from 'xterm';
|
||||
import { ITerminalProcessManager } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ITerminalBackend, ITerminalLogService } from 'vs/platform/terminal/common/terminal';
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
|
|||
import { ITerminalLinkDetector, ITerminalLinkResolver, ITerminalSimpleLink, TerminalBuiltinLinkType } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
|
||||
import { convertLinkRangeToBuffer, getXtermLineContent } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkHelpers';
|
||||
import { ITerminalProcessManager } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { IBufferLine, Terminal } from 'xterm';
|
||||
import type { IBufferLine, Terminal } from 'xterm';
|
||||
import { ITerminalBackend } from 'vs/platform/terminal/common/terminal';
|
||||
|
||||
const enum Constants {
|
||||
|
|
|
@ -12,7 +12,7 @@ import { TerminalSettingId } from 'vs/platform/terminal/common/terminal';
|
|||
import { ITerminalSimpleLink, ITerminalLinkDetector, TerminalBuiltinLinkType } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
|
||||
import { convertLinkRangeToBuffer, getXtermLineContent } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkHelpers';
|
||||
import { ITerminalConfiguration, TERMINAL_CONFIG_SECTION } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { IBufferLine, Terminal } from 'xterm';
|
||||
import type { IBufferLine, Terminal } from 'xterm';
|
||||
|
||||
const enum Constants {
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { deepStrictEqual } from 'assert';
|
||||
import { ITerminalLinkDetector, TerminalLinkType } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IBufferLine } from 'xterm';
|
||||
import type { IBufferLine } from 'xterm';
|
||||
|
||||
export async function assertLinkHelper(
|
||||
text: string,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { IBufferLine, IBufferCell } from 'xterm';
|
||||
import type { IBufferLine, IBufferCell } from 'xterm';
|
||||
import { convertLinkRangeToBuffer } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkHelpers';
|
||||
|
||||
suite('Workbench - Terminal Link Helpers', () => {
|
||||
|
|
|
@ -21,8 +21,9 @@ import { ITerminalCapabilityImplMap, ITerminalCapabilityStore, TerminalCapabilit
|
|||
import { ITerminalConfiguration, ITerminalProcessManager } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { TestViewDescriptorService } from 'vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test';
|
||||
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { ILink, Terminal } from 'xterm';
|
||||
import type { ILink, Terminal } from 'xterm';
|
||||
import { TerminalLinkResolver } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkResolver';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
const defaultTerminalConfig: Partial<ITerminalConfiguration> = {
|
||||
fontFamily: 'monospace',
|
||||
|
@ -61,7 +62,7 @@ suite('TerminalLinkManager', () => {
|
|||
let xterm: Terminal;
|
||||
let linkManager: TestLinkManager;
|
||||
|
||||
setup(() => {
|
||||
setup(async () => {
|
||||
configurationService = new TestConfigurationService({
|
||||
editor: {
|
||||
fastScrollSensitivity: 2,
|
||||
|
@ -82,7 +83,8 @@ suite('TerminalLinkManager', () => {
|
|||
instantiationService.stub(IThemeService, themeService);
|
||||
instantiationService.stub(IViewDescriptorService, viewDescriptorService);
|
||||
|
||||
xterm = new Terminal({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = new TerminalCtor({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
linkManager = instantiationService.createInstance(TestLinkManager, xterm, upcastPartial<ITerminalProcessManager>({
|
||||
get initialCwd() {
|
||||
return '';
|
||||
|
|
|
@ -22,10 +22,11 @@ import { TerminalCapabilityStore } from 'vs/platform/terminal/common/capabilitie
|
|||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
import { IFileQuery, ISearchComplete, ISearchService } from 'vs/workbench/services/search/common/search';
|
||||
import { SearchService } from 'vs/workbench/services/search/common/searchService';
|
||||
import { ITerminalLogService, ITerminalOutputMatcher } from 'vs/platform/terminal/common/terminal';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
interface ITerminalLinkActivationResult {
|
||||
source: 'editor' | 'search';
|
||||
|
@ -75,7 +76,7 @@ suite('Workbench - TerminalLinkOpeners', () => {
|
|||
let activationResult: ITerminalLinkActivationResult | undefined;
|
||||
let xterm: Terminal;
|
||||
|
||||
setup(() => {
|
||||
setup(async () => {
|
||||
instantiationService = new TestInstantiationService();
|
||||
fileService = new TestFileService(new NullLogService());
|
||||
searchService = new TestSearchService(null!, null!, null!, null!, null!, null!, null!);
|
||||
|
@ -108,7 +109,8 @@ suite('Workbench - TerminalLinkOpeners', () => {
|
|||
}
|
||||
}
|
||||
} as Partial<IEditorService>);
|
||||
xterm = new Terminal({ allowProposedApi: true });
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = new TerminalCtor({ allowProposedApi: true });
|
||||
});
|
||||
|
||||
suite('TerminalSearchLinkOpener', () => {
|
||||
|
|
|
@ -12,7 +12,7 @@ import { TerminalBuiltinLinkType } from 'vs/workbench/contrib/terminalContrib/li
|
|||
import { TerminalLocalLinkDetector } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLocalLinkDetector';
|
||||
import { TerminalCapabilityStore } from 'vs/platform/terminal/common/capabilities/terminalCapabilityStore';
|
||||
import { assertLinkHelper } from 'vs/workbench/contrib/terminalContrib/links/test/browser/linkTestUtils';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { strictEqual } from 'assert';
|
||||
import { TerminalLinkResolver } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkResolver';
|
||||
|
@ -21,6 +21,7 @@ import { createFileStat } from 'vs/workbench/test/common/workbenchTestServices';
|
|||
import { URI } from 'vs/base/common/uri';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ITerminalLogService } from 'vs/platform/terminal/common/terminal';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
const unixLinks: (string | { link: string; resource: URI })[] = [
|
||||
// Absolute
|
||||
|
@ -171,7 +172,7 @@ suite('Workbench - TerminalLocalLinkDetector', () => {
|
|||
await assertLinks(TerminalBuiltinLinkType.LocalFile, `[${link}]`, [{ uri, range: [[2, 1], [link.length + 1, 1]] }]);
|
||||
}
|
||||
|
||||
setup(() => {
|
||||
setup(async () => {
|
||||
instantiationService = new TestInstantiationService();
|
||||
configurationService = new TestConfigurationService();
|
||||
instantiationService.stub(IConfigurationService, configurationService);
|
||||
|
@ -187,7 +188,8 @@ suite('Workbench - TerminalLocalLinkDetector', () => {
|
|||
resolver = instantiationService.createInstance(TerminalLinkResolver);
|
||||
validResources = [];
|
||||
|
||||
xterm = new Terminal({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = new TerminalCtor({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
});
|
||||
|
||||
suite('platform independent', () => {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/
|
|||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { TerminalBuiltinLinkType } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
|
||||
import { assertLinkHelper } from 'vs/workbench/contrib/terminalContrib/links/test/browser/linkTestUtils';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { strictEqual } from 'assert';
|
||||
import { TerminalLinkResolver } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalLinkResolver';
|
||||
|
@ -20,6 +20,7 @@ import { URI } from 'vs/base/common/uri';
|
|||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ITerminalLogService } from 'vs/platform/terminal/common/terminal';
|
||||
import { TerminalMultiLineLinkDetector } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalMultiLineLinkDetector';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
const unixLinks: (string | { link: string; resource: URI })[] = [
|
||||
// Absolute
|
||||
|
@ -130,7 +131,7 @@ suite('Workbench - TerminalMultiLineLinkDetector', () => {
|
|||
await assertLinks(TerminalBuiltinLinkType.LocalFile, link, [{ uri, range: [[1, lineCount], [lastLine.length, lineCount]] }]);
|
||||
}
|
||||
|
||||
setup(() => {
|
||||
setup(async () => {
|
||||
instantiationService = new TestInstantiationService();
|
||||
configurationService = new TestConfigurationService();
|
||||
instantiationService.stub(IConfigurationService, configurationService);
|
||||
|
@ -146,7 +147,8 @@ suite('Workbench - TerminalMultiLineLinkDetector', () => {
|
|||
resolver = instantiationService.createInstance(TerminalLinkResolver);
|
||||
validResources = [];
|
||||
|
||||
xterm = new Terminal({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = new TerminalCtor({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
});
|
||||
|
||||
suite('macOS/Linux', () => {
|
||||
|
|
|
@ -13,8 +13,9 @@ import { TerminalUriLinkDetector } from 'vs/workbench/contrib/terminalContrib/li
|
|||
import { assertLinkHelper } from 'vs/workbench/contrib/terminalContrib/links/test/browser/linkTestUtils';
|
||||
import { createFileStat } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
import { OperatingSystem } from 'vs/base/common/platform';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
suite('Workbench - TerminalUriLinkDetector', () => {
|
||||
let configurationService: TestConfigurationService;
|
||||
|
@ -22,7 +23,7 @@ suite('Workbench - TerminalUriLinkDetector', () => {
|
|||
let xterm: Terminal;
|
||||
let validResources: URI[] = [];
|
||||
|
||||
setup(() => {
|
||||
setup(async () => {
|
||||
const instantiationService = new TestInstantiationService();
|
||||
configurationService = new TestConfigurationService();
|
||||
instantiationService.stub(IConfigurationService, configurationService);
|
||||
|
@ -36,7 +37,8 @@ suite('Workbench - TerminalUriLinkDetector', () => {
|
|||
});
|
||||
validResources = [];
|
||||
|
||||
xterm = new Terminal({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = new TerminalCtor({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
detector = instantiationService.createInstance(TerminalUriLinkDetector, xterm, {
|
||||
initialCwd: '/parent/cwd',
|
||||
os: OperatingSystem.Linux,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
|
@ -11,7 +12,7 @@ import { ITerminalSimpleLink, TerminalBuiltinLinkType } from 'vs/workbench/contr
|
|||
import { TerminalWordLinkDetector } from 'vs/workbench/contrib/terminalContrib/links/browser/terminalWordLinkDetector';
|
||||
import { assertLinkHelper } from 'vs/workbench/contrib/terminalContrib/links/test/browser/linkTestUtils';
|
||||
import { TestProductService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
|
||||
suite('Workbench - TerminalWordLinkDetector', () => {
|
||||
let configurationService: TestConfigurationService;
|
||||
|
@ -26,7 +27,8 @@ suite('Workbench - TerminalWordLinkDetector', () => {
|
|||
instantiationService.stub(IConfigurationService, configurationService);
|
||||
instantiationService.set(IProductService, TestProductService);
|
||||
|
||||
xterm = new Terminal({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = new TerminalCtor({ allowProposedApi: true, cols: 80, rows: 30 });
|
||||
detector = instantiationService.createInstance(TerminalWordLinkDetector, xterm);
|
||||
});
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import { localize } from 'vs/nls';
|
|||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { DecorationSelector, updateLayout } from 'vs/workbench/contrib/terminal/browser/xterm/decorationStyles';
|
||||
import { IDecoration, Terminal } from 'xterm';
|
||||
import type { IDecoration, Terminal } from 'xterm';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
|
|
|
@ -19,7 +19,7 @@ import { ITerminalQuickFixService } from 'vs/workbench/contrib/terminalContrib/q
|
|||
import { TerminalQuickFixAddon } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/quickFixAddon';
|
||||
import { freePort, gitCreatePr, gitPushSetUpstream, gitSimilar, gitTwoDashes, pwshGeneralError, pwshUnixCommandNotFoundError } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/terminalQuickFixBuiltinActions';
|
||||
import { TerminalQuickFixService } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/terminalQuickFixService';
|
||||
import { Terminal as RawXtermTerminal } from 'xterm';
|
||||
import type { Terminal as RawXtermTerminal } from 'xterm';
|
||||
|
||||
// Services
|
||||
registerSingleton(ITerminalQuickFixService, TerminalQuickFixService, InstantiationType.Delayed);
|
||||
|
|
|
@ -19,7 +19,7 @@ import { ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/termina
|
|||
import { gitSimilar, freePort, FreePortOutputRegex, gitCreatePr, GitCreatePrOutputRegex, GitPushOutputRegex, gitPushSetUpstream, GitSimilarOutputRegex, gitTwoDashes, GitTwoDashesRegex, pwshUnixCommandNotFoundError, PwshUnixCommandNotFoundErrorOutputRegex, pwshGeneralError, PwshGeneralErrorOutputRegex } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/terminalQuickFixBuiltinActions';
|
||||
import { TerminalQuickFixAddon, getQuickFixesForCommand } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/quickFixAddon';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Terminal } from 'xterm';
|
||||
import type { Terminal } from 'xterm';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { LabelService } from 'vs/workbench/services/label/common/labelService';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
|
@ -29,6 +29,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
|
|||
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { ITerminalQuickFixService } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/quickFix';
|
||||
import { ITerminalOutputMatcher } from 'vs/platform/terminal/common/terminal';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
suite('QuickFixAddon', () => {
|
||||
let quickFixAddon: TerminalQuickFixAddon;
|
||||
|
@ -37,9 +38,10 @@ suite('QuickFixAddon', () => {
|
|||
let openerService: OpenerService;
|
||||
let labelService: LabelService;
|
||||
let terminal: Terminal;
|
||||
setup(() => {
|
||||
setup(async () => {
|
||||
const instantiationService = new TestInstantiationService();
|
||||
terminal = new Terminal({
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('xterm')>('xterm', 'lib/xterm.js')).Terminal;
|
||||
terminal = new TerminalCtor({
|
||||
allowProposedApi: true,
|
||||
cols: 80,
|
||||
rows: 30
|
||||
|
|
|
@ -12,7 +12,7 @@ import { registerTerminalContribution } from 'vs/workbench/contrib/terminal/brow
|
|||
import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/widgets/widgetManager';
|
||||
import { TypeAheadAddon } from 'vs/workbench/contrib/terminalContrib/typeAhead/browser/terminalTypeAheadAddon';
|
||||
import { ITerminalConfiguration, ITerminalProcessManager, TERMINAL_CONFIG_SECTION } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { Terminal as RawXtermTerminal } from 'xterm';
|
||||
import type { Terminal as RawXtermTerminal } from 'xterm';
|
||||
|
||||
class TerminalTypeAheadContribution extends DisposableStore implements ITerminalContribution {
|
||||
static readonly ID = 'terminal.typeAhead';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { IBuffer, Terminal } from 'xterm';
|
||||
import type { IBuffer, Terminal } from 'xterm';
|
||||
import { SinonStub, stub, useFakeTimers } from 'sinon';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { CharPredictState, IPrediction, PredictionStats, TypeAheadAddon } from 'vs/workbench/contrib/terminalContrib/typeAhead/browser/terminalTypeAheadAddon';
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { equals as equalArray } from 'vs/base/common/arrays';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
|
@ -238,7 +239,7 @@ export class TextMateTokenizationFeature extends Disposable implements ITextMate
|
|||
return this._grammarFactory;
|
||||
}
|
||||
|
||||
const [vscodeTextmate, vscodeOniguruma] = await Promise.all([import('vscode-textmate'), this._getVSCodeOniguruma()]);
|
||||
const [vscodeTextmate, vscodeOniguruma] = await Promise.all([importAMDNodeModule<typeof import('vscode-textmate')>('vscode-textmate', 'release/main.js'), this._getVSCodeOniguruma()]);
|
||||
const onigLib: Promise<IOnigLib> = Promise.resolve({
|
||||
createOnigScanner: (sources: string[]) => vscodeOniguruma.createOnigScanner(sources),
|
||||
createOnigString: (str: string) => vscodeOniguruma.createOnigString(str)
|
||||
|
@ -348,7 +349,7 @@ export class TextMateTokenizationFeature extends Disposable implements ITextMate
|
|||
private _getVSCodeOniguruma(): Promise<typeof import('vscode-oniguruma')> {
|
||||
if (!this._vscodeOniguruma) {
|
||||
this._vscodeOniguruma = (async () => {
|
||||
const [vscodeOniguruma, wasm] = await Promise.all([import('vscode-oniguruma'), this._loadVSCodeOnigurumaWASM()]);
|
||||
const [vscodeOniguruma, wasm] = await Promise.all([importAMDNodeModule<typeof import('vscode-oniguruma')>('vscode-oniguruma', 'release/main.js'), this._loadVSCodeOnigurumaWASM()]);
|
||||
await vscodeOniguruma.loadWASM({
|
||||
data: wasm,
|
||||
print: (str: string) => {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { IWorkerContext } from 'vs/editor/common/services/editorSimpleWorker';
|
|||
import type { StateDeltas, TextMateWorkerHost } from 'vs/workbench/services/textMate/browser/workerHost/textMateWorkerHost';
|
||||
import { ICreateGrammarResult, TMGrammarFactory } from 'vs/workbench/services/textMate/common/TMGrammarFactory';
|
||||
import { IValidEmbeddedLanguagesMap, IValidGrammarDefinition, IValidTokenTypeMap } from 'vs/workbench/services/textMate/common/TMScopeRegistry';
|
||||
import { IOnigLib, IRawTheme } from 'vscode-textmate';
|
||||
import type { IOnigLib, IRawTheme } from 'vscode-textmate';
|
||||
import { TextMateWorkerModel } from './textMateWorkerModel';
|
||||
|
||||
export interface ICreateData {
|
||||
|
|
|
@ -10,13 +10,14 @@ import { LineRange } from 'vs/editor/common/core/lineRange';
|
|||
import { LanguageId } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { IModelChangedEvent, MirrorTextModel } from 'vs/editor/common/model/mirrorTextModel';
|
||||
import { TokenizerWithStateStore } from 'vs/editor/common/model/textModelTokens';
|
||||
import type { diffStateStacksRefEq, StateStack, StackDiff } from 'vscode-textmate';
|
||||
import { ContiguousMultilineTokensBuilder } from 'vs/editor/common/tokens/contiguousMultilineTokensBuilder';
|
||||
import { LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { TextMateTokenizationSupport } from 'vs/workbench/services/textMate/browser/tokenizationSupport/textMateTokenizationSupport';
|
||||
import { TokenizationSupportWithLineLimit } from 'vs/workbench/services/textMate/browser/tokenizationSupport/tokenizationSupportWithLineLimit';
|
||||
import { StateDeltas } from 'vs/workbench/services/textMate/browser/workerHost/textMateWorkerHost';
|
||||
import { StackDiff, StateStack, diffStateStacksRefEq } from 'vscode-textmate';
|
||||
import { TextMateTokenizationWorker } from './textMate.worker';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
export class TextMateWorkerModel extends MirrorTextModel {
|
||||
private _tokenizationStateStore: TokenizerWithStateStore<StateStack> | null = null;
|
||||
|
@ -25,6 +26,7 @@ export class TextMateWorkerModel extends MirrorTextModel {
|
|||
'_maxTokenizationLineLength',
|
||||
-1
|
||||
);
|
||||
private _diffStateStacksRefEqFn?: typeof diffStateStacksRefEq;
|
||||
|
||||
constructor(
|
||||
uri: URI,
|
||||
|
@ -107,11 +109,16 @@ export class TextMateWorkerModel extends MirrorTextModel {
|
|||
});
|
||||
}
|
||||
|
||||
private _tokenize(): void {
|
||||
private async _tokenize(): Promise<void> {
|
||||
if (this._isDisposed || !this._tokenizationStateStore) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._diffStateStacksRefEqFn) {
|
||||
const { diffStateStacksRefEq } = await importAMDNodeModule<typeof import('vscode-textmate')>('vscode-textmate', 'release/main.js');
|
||||
this._diffStateStacksRefEqFn = diffStateStacksRefEq;
|
||||
}
|
||||
|
||||
const startTime = new Date().getTime();
|
||||
|
||||
while (true) {
|
||||
|
@ -131,7 +138,7 @@ export class TextMateWorkerModel extends MirrorTextModel {
|
|||
const lineStartState = this._tokenizationStateStore.getStartState(lineNumberToTokenize)!;
|
||||
const r = this._tokenizationStateStore.tokenizationSupport.tokenizeEncoded(text, true, lineStartState);
|
||||
if (this._tokenizationStateStore.store.setEndState(lineNumberToTokenize, r.endState as StateStack)) {
|
||||
const delta = diffStateStacksRefEq(lineStartState, r.endState as StateStack);
|
||||
const delta = this._diffStateStacksRefEqFn(lineStartState, r.endState as StateStack);
|
||||
stateDeltaBuilder.setState(lineNumberToTokenize, delta);
|
||||
} else {
|
||||
stateDeltaBuilder.setState(lineNumberToTokenize, null);
|
||||
|
|
|
@ -23,7 +23,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
|||
import { ICreateData, TextMateTokenizationWorker } from 'vs/workbench/services/textMate/browser/worker/textMate.worker';
|
||||
import { TextMateWorkerTokenizerController } from 'vs/workbench/services/textMate/browser/workerHost/textMateWorkerTokenizerController';
|
||||
import { IValidGrammarDefinition } from 'vs/workbench/services/textMate/common/TMScopeRegistry';
|
||||
import { INITIAL, IRawTheme, StackDiff } from 'vscode-textmate';
|
||||
import type { IRawTheme, StackDiff } from 'vscode-textmate';
|
||||
|
||||
export class TextMateWorkerHost implements IDisposable {
|
||||
private static _reportedMismatchingTokens = false;
|
||||
|
@ -152,7 +152,7 @@ export class TextMateWorkerHost implements IDisposable {
|
|||
}
|
||||
|
||||
store.add(keepAliveWhenAttached(textModel, () => {
|
||||
const controller = new TextMateWorkerTokenizerController(textModel, workerProxy, this._languageService.languageIdCodec, tokenStore, INITIAL, this._configurationService, maxTokenizationLineLength);
|
||||
const controller = new TextMateWorkerTokenizerController(textModel, workerProxy, this._languageService.languageIdCodec, tokenStore, this._configurationService, maxTokenizationLineLength);
|
||||
this._workerTokenizerControllers.set(textModel.uri.toString(), controller);
|
||||
|
||||
return toDisposable(() => {
|
||||
|
@ -235,4 +235,3 @@ function keepAliveWhenAttached(textModel: ITextModel, factory: () => IDisposable
|
|||
}));
|
||||
return disposableStore;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IObservable, autorun, keepAlive, observableFromEvent } from 'vs/base/common/observable';
|
||||
import { countEOL } from 'vs/editor/common/core/eolCounter';
|
||||
|
@ -17,7 +18,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
|||
import { ArrayEdit, MonotonousIndexTransformer, SingleArrayEdit } from 'vs/workbench/services/textMate/browser/arrayOperation';
|
||||
import { TextMateTokenizationWorker } from 'vs/workbench/services/textMate/browser/worker/textMate.worker';
|
||||
import type { StateDeltas } from 'vs/workbench/services/textMate/browser/workerHost/textMateWorkerHost';
|
||||
import { applyStateStackDiff, StateStack } from 'vscode-textmate';
|
||||
import type { applyStateStackDiff, StateStack } from 'vscode-textmate';
|
||||
|
||||
export class TextMateWorkerTokenizerController extends Disposable {
|
||||
private _pendingChanges: IModelContentChangedEvent[] = [];
|
||||
|
@ -30,12 +31,14 @@ export class TextMateWorkerTokenizerController extends Disposable {
|
|||
|
||||
private readonly _loggingEnabled = observableConfigValue('editor.experimental.asyncTokenizationLogging', false, this._configurationService);
|
||||
|
||||
private _applyStateStackDiffFn?: typeof applyStateStackDiff;
|
||||
private _initialState?: StateStack;
|
||||
|
||||
constructor(
|
||||
private readonly _model: ITextModel,
|
||||
private readonly _worker: TextMateTokenizationWorker,
|
||||
private readonly _languageIdCodec: ILanguageIdCodec,
|
||||
private readonly _backgroundTokenizationStore: IBackgroundTokenizationStore,
|
||||
private readonly _initialState: StateStack,
|
||||
private readonly _configurationService: IConfigurationService,
|
||||
private readonly _maxTokenizationLineLength: IObservable<number>,
|
||||
) {
|
||||
|
@ -95,7 +98,7 @@ export class TextMateWorkerTokenizerController extends Disposable {
|
|||
/**
|
||||
* This method is called from the worker through the worker host.
|
||||
*/
|
||||
public setTokensAndStates(versionId: number, rawTokens: ArrayBuffer, stateDeltas: StateDeltas[]): void {
|
||||
public async setTokensAndStates(versionId: number, rawTokens: ArrayBuffer, stateDeltas: StateDeltas[]): Promise<void> {
|
||||
// _states state, change{k}, ..., change{versionId}, state delta base & rawTokens, change{j}, ..., change{m}, current renderer state
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// | past changes | future states
|
||||
|
@ -165,6 +168,13 @@ export class TextMateWorkerTokenizerController extends Disposable {
|
|||
this._pendingChanges.map((c) => fullLineArrayEditFromModelContentChange(c.changes))
|
||||
);
|
||||
|
||||
if (!this._applyStateStackDiffFn || !this._initialState) {
|
||||
const { applyStateStackDiff, INITIAL } = await importAMDNodeModule<typeof import('vscode-textmate')>('vscode-textmate', 'release/main.js');
|
||||
this._applyStateStackDiffFn = applyStateStackDiff;
|
||||
this._initialState = INITIAL;
|
||||
}
|
||||
|
||||
|
||||
// Apply state deltas to _states and _backgroundTokenizationStore
|
||||
for (const d of stateDeltas) {
|
||||
let prevState = d.startLineNumber <= 1 ? this._initialState : this._states.getEndState(d.startLineNumber - 1);
|
||||
|
@ -172,7 +182,7 @@ export class TextMateWorkerTokenizerController extends Disposable {
|
|||
const delta = d.stateDeltas[i];
|
||||
let state: StateStack;
|
||||
if (delta) {
|
||||
state = applyStateStackDiff(prevState, delta)!;
|
||||
state = this._applyStateStackDiffFn(prevState, delta)!;
|
||||
this._states.setEndState(d.startLineNumber + i, state);
|
||||
} else {
|
||||
state = this._states.getEndState(d.startLineNumber + i)!;
|
||||
|
|
|
@ -7,10 +7,10 @@ import * as assert from 'assert';
|
|||
import * as fs from 'fs';
|
||||
import * as encoding from 'vs/workbench/services/textfile/common/encoding';
|
||||
import * as streams from 'vs/base/common/stream';
|
||||
import * as iconv from '@vscode/iconv-lite-umd';
|
||||
import { newWriteableBufferStream, VSBuffer, VSBufferReadableStream, streamToBufferReadableStream } from 'vs/base/common/buffer';
|
||||
import { splitLines } from 'vs/base/common/strings';
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
import { importAMDNodeModule } from 'vs/amdX';
|
||||
|
||||
export async function detectEncodingByBOM(file: string): Promise<typeof encoding.UTF16be | typeof encoding.UTF16le | typeof encoding.UTF8_with_bom | null> {
|
||||
try {
|
||||
|
@ -213,7 +213,7 @@ suite('Encoding', () => {
|
|||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(iconv.decode(data, encoding.toNodeEncoding(fileEncoding!)));
|
||||
resolve(importAMDNodeModule<typeof import('@vscode/iconv-lite-umd')>('@vscode/iconv-lite-umd', 'lib/iconv-lite-umd.js').then(iconv => iconv.decode(data, encoding.toNodeEncoding(fileEncoding!))));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -385,6 +385,8 @@ suite('Encoding', () => {
|
|||
const path = FileAccess.asFileUri('vs/workbench/services/textfile/test/node/encoding/fixtures/some_utf16be.css').fsPath;
|
||||
const source = await readAndDecodeFromDisk(path, encoding.UTF16be);
|
||||
|
||||
const iconv = await importAMDNodeModule<typeof import('@vscode/iconv-lite-umd')>('@vscode/iconv-lite-umd', 'lib/iconv-lite-umd.js');
|
||||
|
||||
const expected = VSBuffer.wrap(
|
||||
iconv.encode(source, encoding.toNodeEncoding(encoding.UTF16be))
|
||||
).toString();
|
||||
|
@ -446,7 +448,7 @@ suite('Encoding', () => {
|
|||
if (enc === encoding.UTF8_with_bom) {
|
||||
continue; // skip over encodings from us
|
||||
}
|
||||
|
||||
const iconv = await importAMDNodeModule<typeof import('@vscode/iconv-lite-umd')>('@vscode/iconv-lite-umd', 'lib/iconv-lite-umd.js');
|
||||
assert.strictEqual(iconv.encodingExists(enc), true, enc);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue