mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 01:28:26 -05:00
Merge VS Code 1.26.1 (#2394)
* Squash merge commits for 1.26 (#1) (#2323) * Polish tag search as per feedback (#55269) * Polish tag search as per feedback * Updated regex * Allow users to opt-out of features that send online requests in the background (#55097) * settings sweep #54690 * Minor css tweaks to enable eoverflow elipsis in more places (#55277) * fix an issue with titlebarheight when not scaling with zoom * Settings descriptions update #54690 * fixes #55209 * Settings editor - many padding fixes * More space above level 2 label * Fixing Cannot debug npm script using Yarn #55103 * Settings editor - show ellipsis when description overflows * Settings editor - ... fix measuring around links, relayout * Setting descriptions * Settings editor - fix ... for some short lines, fix select container width * Settings editor - overlay trees so scrollable shadow is full width * Fix #54133 - missing extension settings after reload * Settings color token description tweak * Settings editor - disable overflow indicator temporarily, needs to be faster * Added command to Run the selected npm script * fixes #54452 * fixes #54929 * fixes #55248 * prefix command with extension name * Contribute run selected to the context menu * node-debug@1.26.6 * Allow terminal rendererType to be swapped out at runtime Part of #53274 Fixes #55344 * Settings editor - fix not focusing search when restoring editor setInput must be actually async. Will be fixed naturally when we aren't using winJS promises... * Settings editor - TOC should only expand the section with a selected item * Bump node-debug2 * Settings editor - Tree focus outlines * Settings editor - don't blink the scrollbar when toc selection changes And hide TOC correctly when the editor is narrow * Settings editor - header rows should not be selectable * fixes #54877 * change debug assignee to isi * Settings sweep (#54690) * workaround for #55051 * Settings sweep (#54690) * settings sweep #54690 * Don't try closing tags when you type > after another > * Describe what implementation code lens does Fixes #55370 * fix javadoc formatter setting description * fixes #55325 * update to officical TS version * Settings editor - Even more padding, use semibold instead of bold * Fix #55357 - fix TOC twistie * fixes #55288 * explorer: refresh on di change file system provider registration fixes #53256 * Disable push to Linux repo to test standalone publisher * New env var to notify log level to extensions #54001 * Disable snippets in extension search (when not in suggest dropdown) (#55281) * Disable snippits in extension search (when not in suggest dropdown) * Add monaco input contributions * Fix bug preventing snippetSuggestions from taking effect in sub-editors * Latest emmet helper to fix #52366 * Fix comment updates for threads within same file * Allow extensions to log telemetry to log files #54001 * Pull latest css grammar * files.exclude control - use same style for "add" vs "edit" * files.exclude control - focus/keyboard behavior * don't show menubar too early * files.exclude - better styling * Place cursor at end of extensions search box on autofill (#55254) * Place cursor at end of extensions search box on autofill * Use position instead of selection * fix linux build issue (empty if block) * Settings editor - fix extension category prefixes * Settings editor - add simple ellipsis for first line that overflows, doesn't cover case when first line does not overflow but there is more text, TODO * File/Text search provider docs * Fixes #52655 * Include epoch (#55008) * Fixes #53385 * Fixes #49480 * VS Code Insiders (Users) not opening Fixes #55353 * Better handling of the case when the extension host fails to start * Fixes #53966 * Remove confusing Start from wordPartLeft commands ID * vscode-xterm@3.6.0-beta12 Fixes #55488 * Initial size is set to infinity!! Fixes #55461 * Polish embeddedEditorBackground * configuration service misses event * Fix #55224 - fix duplicate results in multiroot workspace from splitting the diskseach query * Select all not working in issue reporter on mac, fixes #55424 * Disable fuzzy matching for extensions autosuggest (#55498) * Fix clipping of extensions search border in some third party themes (#55504) * fixes #55538 * Fix bug causing an aria alert to not be shown the third time (and odd numbers thereafter) * Settings editor - work around rendering glitch with webkit-line-clamp * Settings editor - revert earlier '...' changes * Settings editor - move enumDescription to its own div, because it disturbs -webkit-line-clamp for some reason * Settings editor - better overflow indicator * Don't show existing filters in autocomplete (#55495) * Dont show existing filters in autocomplete * Simplify * Settings Editor: Add aria labels for input elements Fixes: #54836 (#55543) * fixes #55223 * Update vscode-css-languageservice to 3.0.10-next.1 * Fix #55509 - settings navigation * Fix #55519 * Fix #55520 * FIx #55524 * Fix #55556 - include wordSeparators in all search queries, so findTextInFiles can respect isWordMatch correctly * oss updates for endgame * Fix unit tests * fixes #55522 * Avoid missing manifest error from bubbling up #54757 * Settings format crawl * Search provider - Fix FileSearchProvider to return array, not progress * Fix #55598 * Settings editor - fix NPE rendering settings with no description * dont render inden guides in search box (#55600) * fixes #55454 * More settings crawl * Another change for #55598 - maxResults applies to FileSearch and TextSearch but not FileIndex * Fix FileSearchProvider unit tests for progress change * fixes #55561 * Settings description update for #54690 * Update setting descriptions for online services * Minor edits * fixes #55513 * fixes #55451 * Fix #55612 - fix findTextInFiles cancellation * fixes #55539 * More setting description tweaks * Setting to disable online experiments #54354 * fixes #55507 * fixes #55515 * Show online services action only in Insiders for now * Settings editor - change toc behavior default to 'filter' * Settings editor - nicer filter count style during search * Fix #55617 - search viewlet icons * Settings editor - better styling for element count indicator * SearchProvider - fix NPE when searching extraFileResources * Allow extends to work without json suffix Fixes #16905 * Remove accessability options logic entirely Follow up on #55451 * use latest version of DAP * fixes #55490 * fixes #55122 * fixes #52332 * Avoid assumptions about git: URIs (fixes #36236) * relative path for descriptions * resourece: get rid of isFile context key fixes #48275 * Register previous ids for compatibility (#53497) * more tuning for #48275 * no need to always re-read "files explorer" fixes #52003 * read out active composites properly fixes #51967 * Update link colors for hc theme to meet color contrast ratio, fixes #55651 Also updated link color for `textLinkActiveForeground` to be the same as `textLinkForeground` as it wasn't properly updated * detect 'winpty-agent.exe'; fixes #55672 * node-debug@1.26.7 * reset counter on new label * Settings editor - fix multiple setting links in one description * Settings editor - color code blocks in setting descriptions, fix #55532 * Settings editor - hover color in TOC * Settings editor - fix navigation NPE * Settings editor - fix text control width * Settings editor - maybe fix #55684 * Fix bug causing cursor to not move on paste * fixes #53582 * Use ctrlCmd instead of ctrl for go down from search box * fixes #55264 * fixes #55456 * filter for spcaes before triggering search (#55611) * Fix #55698 - don't lose filtered TOC counts when refreshing TOC * fixes #55421 * fixes #28979 * fixes #55576 * only add check for updates to windows/linux help * readonly files: append decoration to label fixes #53022 * debug: do not show toolbar while initialising fixes #55026 * Opening launch.json should not activate debug extensions fixes #55029 * fixes #55435 * fixes #55434 * fixes #55439 * trigger menu only on altkey up * Fix #50555 - fix settings editor memory leak * Fix #55712 - no need to focus 'a' anymore when restoring control focus after tree render * fixes #55335 * proper fix for readonly model fixes #53022 * improve FoldingRangeKind spec (for #55686) * Use class with static fields (fixes #55494) * Fixes #53671 * fixes #54630 * [html] should disable ionic suggestions by default. Currently forces deprecated Ionic v1 suggestions in .html files while typing. Fixes #53324 * cleanup deps * debug issues back to andre * update electron for smoketest * Fix #55757 - prevent settings tabs from overflowing * Fix #53897 - revert setting menu defaults to old editor * Add enum descriptions to `typescript.preferences.importModuleSpecifier` * Fix #55767 - leaking style elements from settings editor * Fix #55521 - prevent flashing when clicking in exclude control * Update Git modified color for contrast ratio, fixes #53140 * Revert "Merge branch 'master' of github.com:Microsoft/vscode" This reverts commit bf46b6bfbae0cab99c2863e1244a916181fa9fbc, reversing changes made to e275a424483dfb4ed33b428c97d5e2c441d6b917. * Revert "Revert "Merge branch 'master' of github.com:Microsoft/vscode"" This reverts commit 53949d963f39e40757557c6526332354a31d9154. * don't ask to install an incomplete menu * Fix NPE in terminal AccessibilityManager Fixes #55744 * don't display fallback menu unless we've closed the last window * fixes #55547 * Fix smoke tests for extension search box * Update OSSREADME.json for Electron 2.0.5 * Update distro Includes Chromium license changes * fix #55455 * fix #55865 * fixes #55893 * Fix bug causing workspace recommendations to go away upon ignoring a recommendation (#55805) * Fix bug causing workspace recommendations to go away upon ignoring a recommendation * ONly show on @recommended or @recommended:workspace * Make more consistant * Fix #55911 * Understand json activity (#55926) * Understand json file activity * Refactoring * adding composer.json * Distro update for experiments * use terminal.processId for auto-attach; fixes #55918 * Reject invalid URI with vscode.openFolder (for #55891) * improve win32 setup system vs user detection fixes #55840 fixes #55840 delay winreg import related to #55840 show notification earlier related to #55840 fix #55840 update inno setup message related to #55840 * Fix #55593 - this code only operates on local paths, so use fsPath and Uri.file instead * Bring back the old menu due to electron 2.0 issues (#55913) * add the old menu back for native menus * make menu labels match * `vscode.openFolder`: treat missing URI schema gracefully (for #55891) * delay EH reattach; fixes #55955 * Mark all json files under appSettingsHome as settings * Use localized strings for telemetry opt-out * Exception when saving file editor opened from remote file provider (fixes #55051) * Remove terminal menu from stable Fixes 56003 * VSCode Insiders crashes on open with TypeError: Cannot read property 'lastIndexOf' of undefined. Fixes #54933 * improve fix for #55891 * fix #55916 * Improve #55891 * increase EH debugging restart delay; fixes #55955 * Revert "Don't include non-resource entries in history quick pick" This reverts commit 37209a838e9f7e9abe6dc53ed73cdf1e03b72060. * Diff editor: horizontal scrollbar height is smaller (fixes #56062) * improve openFolder uri fix (correctly treat backslashes) * fixes #56116 repair ipc for native menubar keybindings * Fix #56240 - Open the JSON settings editor instead of the UI editor * Fix #55536 * uriDisplay: if no formatter is registered fall back to getPathlabel fixes #56104 * VSCode hangs when opening python file. Fixes #56377 * VS Code Hangs When Opening Specific PowerShell File. Fixes #56430 * Fix #56433 - search extraFileResources even when no folders open * Workaround #55649 * Fix in master #56371 * Fix tests #56371 * Fix in master #56317 * increase version to 1.26.1 * Fixes #56387: Handle SIGPIPE in extension host * fixes #56185 * Fix merge issues (part 1) * Fix build breaks (part 1) * Build breaks (part 2) * Build breaks (part 3) * More build breaks (part 4) * Fix build breaks (part 5) * WIP * Fix menus * Render query result and message panels (#2363) * Put back query editor hot exit changes * Fix grid changes that broke profiler (#2365) * Update APIs for saving query editor state * Fix restore view state for profiler and edit data * Updating custom default themes to support 4.5:1 contrast ratio * Test updates * Fix Extension Manager and Windows Setup * Update license headers * Add appveyor and travis files back * Fix hidden modal dropdown issue
This commit is contained in:
@@ -10,7 +10,7 @@ import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { prepareActions } from 'vs/workbench/browser/actions';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
|
||||
suite('Workbench Action Registry', () => {
|
||||
suite('Workbench action registry', () => {
|
||||
|
||||
test('Workbench Action Bar prepareActions()', function () {
|
||||
let a1 = new Separator();
|
||||
|
||||
@@ -80,7 +80,7 @@ class MyPart3 extends Part {
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench Part', () => {
|
||||
suite('Workbench parts', () => {
|
||||
let fixture: HTMLElement;
|
||||
let fixtureId = 'workbench-part-fixture';
|
||||
let storage: IStorageService;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { BaseEditor, EditorMemento } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorInput, EditorOptions, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -14,11 +14,14 @@ import * as Platform from 'vs/platform/registry/common/platform';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { workbenchInstantiationService, TestEditorGroup, TestEditorGroupsService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IEditorRegistry, Extensions, EditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IEditorModel } from 'vs/platform/editor/common/editor';
|
||||
|
||||
const NullThemeService = new TestThemeService();
|
||||
|
||||
@@ -31,17 +34,9 @@ export class MyEditor extends BaseEditor {
|
||||
super('MyEditor', NullTelemetryService, NullThemeService);
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return 'myEditor';
|
||||
}
|
||||
|
||||
public layout(): void {
|
||||
|
||||
}
|
||||
|
||||
public createEditor(): any {
|
||||
|
||||
}
|
||||
getId(): string { return 'myEditor'; }
|
||||
layout(): void { }
|
||||
createEditor(): any { }
|
||||
}
|
||||
|
||||
export class MyOtherEditor extends BaseEditor {
|
||||
@@ -50,17 +45,10 @@ export class MyOtherEditor extends BaseEditor {
|
||||
super('myOtherEditor', NullTelemetryService, NullThemeService);
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return 'myOtherEditor';
|
||||
}
|
||||
getId(): string { return 'myOtherEditor'; }
|
||||
|
||||
public layout(): void {
|
||||
|
||||
}
|
||||
|
||||
public createEditor(): any {
|
||||
|
||||
}
|
||||
layout(): void { }
|
||||
createEditor(): any { }
|
||||
}
|
||||
|
||||
class MyInputFactory implements IEditorInputFactory {
|
||||
@@ -79,27 +67,27 @@ class MyInput extends EditorInput {
|
||||
return ids[1];
|
||||
}
|
||||
|
||||
public getTypeId(): string {
|
||||
getTypeId(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public resolve(refresh?: boolean): any {
|
||||
resolve(): any {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class MyOtherInput extends EditorInput {
|
||||
public getTypeId(): string {
|
||||
getTypeId(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public resolve(refresh?: boolean): any {
|
||||
resolve(): any {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
class MyResourceInput extends ResourceEditorInput { }
|
||||
|
||||
suite('Workbench BaseEditor', () => {
|
||||
suite('Workbench base editor', () => {
|
||||
|
||||
test('BaseEditor API', function () {
|
||||
let e = new MyEditor(NullTelemetryService);
|
||||
@@ -109,18 +97,20 @@ suite('Workbench BaseEditor', () => {
|
||||
assert(!e.isVisible());
|
||||
assert(!e.input);
|
||||
assert(!e.options);
|
||||
return e.setInput(input, options).then(() => {
|
||||
return e.setInput(input, options, CancellationToken.None).then(() => {
|
||||
assert.strictEqual(input, e.input);
|
||||
assert.strictEqual(options, e.options);
|
||||
|
||||
e.setVisible(true);
|
||||
const group = new TestEditorGroup(1);
|
||||
e.setVisible(true, group);
|
||||
assert(e.isVisible());
|
||||
assert.equal(e.group, group);
|
||||
input.onDispose(() => {
|
||||
assert(false);
|
||||
});
|
||||
e.dispose();
|
||||
e.clearInput();
|
||||
e.setVisible(false);
|
||||
e.setVisible(false, group);
|
||||
assert(!e.isVisible());
|
||||
assert(!e.input);
|
||||
assert(!e.options);
|
||||
@@ -200,6 +190,116 @@ suite('Workbench BaseEditor', () => {
|
||||
assert(factory);
|
||||
});
|
||||
|
||||
test('EditorMemento - basics', function () {
|
||||
const testGroup0 = new TestEditorGroup(0);
|
||||
const testGroup1 = new TestEditorGroup(1);
|
||||
const testGroup4 = new TestEditorGroup(4);
|
||||
|
||||
const editorGroupService = new TestEditorGroupsService([
|
||||
testGroup0,
|
||||
testGroup1,
|
||||
new TestEditorGroup(2)
|
||||
]);
|
||||
|
||||
interface TestViewState {
|
||||
line: number;
|
||||
}
|
||||
|
||||
const rawMemento = Object.create(null);
|
||||
let memento = new EditorMemento<TestViewState>('id', 'key', rawMemento, 3, editorGroupService);
|
||||
|
||||
let res = memento.loadState(testGroup0, URI.file('/A'));
|
||||
assert.ok(!res);
|
||||
|
||||
memento.saveState(testGroup0, URI.file('/A'), { line: 3 });
|
||||
res = memento.loadState(testGroup0, URI.file('/A'));
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 3);
|
||||
|
||||
memento.saveState(testGroup1, URI.file('/A'), { line: 5 });
|
||||
res = memento.loadState(testGroup1, URI.file('/A'));
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 5);
|
||||
|
||||
// Ensure capped at 3 elements
|
||||
memento.saveState(testGroup0, URI.file('/B'), { line: 1 });
|
||||
memento.saveState(testGroup0, URI.file('/C'), { line: 1 });
|
||||
memento.saveState(testGroup0, URI.file('/D'), { line: 1 });
|
||||
memento.saveState(testGroup0, URI.file('/E'), { line: 1 });
|
||||
|
||||
assert.ok(!memento.loadState(testGroup0, URI.file('/A')));
|
||||
assert.ok(!memento.loadState(testGroup0, URI.file('/B')));
|
||||
assert.ok(memento.loadState(testGroup0, URI.file('/C')));
|
||||
assert.ok(memento.loadState(testGroup0, URI.file('/D')));
|
||||
assert.ok(memento.loadState(testGroup0, URI.file('/E')));
|
||||
|
||||
// Save at an unknown group
|
||||
memento.saveState(testGroup4, URI.file('/E'), { line: 1 });
|
||||
assert.ok(memento.loadState(testGroup4, URI.file('/E'))); // only gets removed when memento is saved
|
||||
memento.saveState(testGroup4, URI.file('/C'), { line: 1 });
|
||||
assert.ok(memento.loadState(testGroup4, URI.file('/C'))); // only gets removed when memento is saved
|
||||
|
||||
memento.shutdown();
|
||||
|
||||
memento = new EditorMemento('id', 'key', rawMemento, 3, editorGroupService);
|
||||
assert.ok(memento.loadState(testGroup0, URI.file('/C')));
|
||||
assert.ok(memento.loadState(testGroup0, URI.file('/D')));
|
||||
assert.ok(memento.loadState(testGroup0, URI.file('/E')));
|
||||
|
||||
// Check on entries no longer there from invalid groups
|
||||
assert.ok(!memento.loadState(testGroup4, URI.file('/E')));
|
||||
assert.ok(!memento.loadState(testGroup4, URI.file('/C')));
|
||||
|
||||
memento.clearState(URI.file('/C'));
|
||||
memento.clearState(URI.file('/E'));
|
||||
|
||||
assert.ok(!memento.loadState(testGroup0, URI.file('/C')));
|
||||
assert.ok(memento.loadState(testGroup0, URI.file('/D')));
|
||||
assert.ok(!memento.loadState(testGroup0, URI.file('/E')));
|
||||
});
|
||||
|
||||
test('EditoMemento - use with editor input', function () {
|
||||
const testGroup0 = new TestEditorGroup(0);
|
||||
|
||||
interface TestViewState {
|
||||
line: number;
|
||||
}
|
||||
|
||||
class TestEditorInput extends EditorInput {
|
||||
constructor(private resource: URI, private id = 'testEditorInput') {
|
||||
super();
|
||||
}
|
||||
public getTypeId() { return 'testEditorInput'; }
|
||||
public resolve(): TPromise<IEditorModel> { return null; }
|
||||
|
||||
public matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
}
|
||||
|
||||
public getResource(): URI {
|
||||
return this.resource;
|
||||
}
|
||||
}
|
||||
|
||||
const rawMemento = Object.create(null);
|
||||
let memento = new EditorMemento<TestViewState>('id', 'key', rawMemento, 3, new TestEditorGroupsService());
|
||||
|
||||
const testInputA = new TestEditorInput(URI.file('/A'));
|
||||
|
||||
let res = memento.loadState(testGroup0, testInputA);
|
||||
assert.ok(!res);
|
||||
|
||||
memento.saveState(testGroup0, testInputA, { line: 3 });
|
||||
res = memento.loadState(testGroup0, testInputA);
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 3);
|
||||
|
||||
// State removed when input gets disposed
|
||||
testInputA.dispose();
|
||||
res = memento.loadState(testGroup0, testInputA);
|
||||
assert.ok(!res);
|
||||
});
|
||||
|
||||
return {
|
||||
MyEditor: MyEditor,
|
||||
MyOtherEditor: MyOtherEditor
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { Workspace, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { EditorBreadcrumbsModel, FileElement } from 'vs/workbench/browser/parts/editor/breadcrumbsModel';
|
||||
import { TestContextService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { FileKind } from 'vs/platform/files/common/files';
|
||||
|
||||
|
||||
suite('Breadcrumb Model', function () {
|
||||
|
||||
const workspaceService = new TestContextService(new Workspace('ffff', 'Test', [new WorkspaceFolder({ uri: URI.parse('foo:/bar/baz/ws'), name: 'ws', index: 0 })]));
|
||||
const configService = new class extends TestConfigurationService {
|
||||
getValue(...args: any[]) {
|
||||
if (args[0] === 'breadcrumbs.filePath') {
|
||||
return 'on';
|
||||
}
|
||||
if (args[0] === 'breadcrumbs.symbolPath') {
|
||||
return 'on';
|
||||
}
|
||||
return super.getValue(...args);
|
||||
}
|
||||
};
|
||||
|
||||
test('only uri, inside workspace', function () {
|
||||
|
||||
let model = new EditorBreadcrumbsModel(URI.parse('foo:/bar/baz/ws/some/path/file.ts'), undefined, workspaceService, configService);
|
||||
let elements = model.getElements();
|
||||
|
||||
assert.equal(elements.length, 3);
|
||||
let [one, two, three] = elements as FileElement[];
|
||||
assert.equal(one.kind, FileKind.FOLDER);
|
||||
assert.equal(two.kind, FileKind.FOLDER);
|
||||
assert.equal(three.kind, FileKind.FILE);
|
||||
assert.equal(one.uri.toString(), 'foo:/bar/baz/ws/some');
|
||||
assert.equal(two.uri.toString(), 'foo:/bar/baz/ws/some/path');
|
||||
assert.equal(three.uri.toString(), 'foo:/bar/baz/ws/some/path/file.ts');
|
||||
});
|
||||
|
||||
test('only uri, outside workspace', function () {
|
||||
|
||||
let model = new EditorBreadcrumbsModel(URI.parse('foo:/outside/file.ts'), undefined, workspaceService, configService);
|
||||
let elements = model.getElements();
|
||||
|
||||
assert.equal(elements.length, 2);
|
||||
let [one, two] = elements as FileElement[];
|
||||
assert.equal(one.kind, FileKind.FOLDER);
|
||||
assert.equal(two.kind, FileKind.FILE);
|
||||
assert.equal(one.uri.toString(), 'foo:/outside');
|
||||
assert.equal(two.uri.toString(), 'foo:/outside/file.ts');
|
||||
});
|
||||
});
|
||||
@@ -6,16 +6,13 @@
|
||||
import * as assert from 'assert';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { TestEditorService, workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { workbenchInstantiationService, TestEditorService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
|
||||
import * as WorkbenchEditorService from 'vs/workbench/services/editor/common/editorService';
|
||||
import { RangeHighlightDecorations } from 'vs/workbench/browser/parts/editor/rangeDecorations';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { IEditorInput } from 'vs/platform/editor/common/editor';
|
||||
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -23,6 +20,7 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { CoreNavigationCommands } from 'vs/editor/browser/controller/coreCommands';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
||||
suite('Editor - Range decorations', () => {
|
||||
|
||||
@@ -35,15 +33,15 @@ suite('Editor - Range decorations', () => {
|
||||
|
||||
setup(() => {
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
instantiationService.stub(WorkbenchEditorService.IWorkbenchEditorService, new TestEditorService());
|
||||
instantiationService.stub(IEditorService, new TestEditorService());
|
||||
instantiationService.stub(IModeService, ModeServiceImpl);
|
||||
instantiationService.stub(IModelService, stubModelService(instantiationService));
|
||||
text = 'LINE1' + '\n' + 'LINE2' + '\n' + 'LINE3' + '\n' + 'LINE4' + '\r\n' + 'LINE5';
|
||||
model = aModel(URI.file('some_file'));
|
||||
codeEditor = createTestCodeEditor(model);
|
||||
mockEditorService(codeEditor.getModel().uri);
|
||||
codeEditor = createTestCodeEditor({ model: model });
|
||||
|
||||
instantiationService.stub(WorkbenchEditorService.IWorkbenchEditorService, 'getActiveEditor', { getControl: () => { return codeEditor; } });
|
||||
instantiationService.stub(IEditorService, 'activeEditor', { getResource: () => { return codeEditor.getModel().uri; } });
|
||||
instantiationService.stub(IEditorService, 'activeTextEditorWidget', codeEditor);
|
||||
|
||||
testObject = instantiationService.createInstance(RangeHighlightDecorations);
|
||||
});
|
||||
@@ -134,7 +132,6 @@ suite('Editor - Range decorations', () => {
|
||||
function prepareActiveEditor(resource: string): TextModel {
|
||||
let model = aModel(URI.file(resource));
|
||||
codeEditor.setModel(model);
|
||||
mockEditorService(model.uri);
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -144,13 +141,6 @@ suite('Editor - Range decorations', () => {
|
||||
return model;
|
||||
}
|
||||
|
||||
function mockEditorService(editorInput: IEditorInput);
|
||||
function mockEditorService(resource: URI);
|
||||
function mockEditorService(arg: any) {
|
||||
let editorInput: IEditorInput = arg instanceof URI ? instantiationService.createInstance(FileEditorInput, arg, void 0) : arg;
|
||||
instantiationService.stub(WorkbenchEditorService.IWorkbenchEditorService, 'getActiveEditorInput', editorInput);
|
||||
}
|
||||
|
||||
function rangeHighlightDecorations(m: TextModel): IRange[] {
|
||||
let rangeHighlights: IRange[] = [];
|
||||
|
||||
|
||||
@@ -4,15 +4,16 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ContributableViewsModel } from 'vs/workbench/browser/parts/views/contributableViews';
|
||||
import { ViewLocation, ViewsRegistry, IViewDescriptor } from 'vs/workbench/common/views';
|
||||
import { ContributableViewsModel } from 'vs/workbench/browser/parts/views/views';
|
||||
import { ViewsRegistry, IViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions } from 'vs/workbench/common/views';
|
||||
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { SimpleConfigurationService } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { move } from 'vs/base/common/arrays';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
|
||||
const location = ViewLocation.register('test');
|
||||
const container = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer('test');
|
||||
|
||||
class ViewDescriptorSequence {
|
||||
|
||||
@@ -21,8 +22,8 @@ class ViewDescriptorSequence {
|
||||
|
||||
constructor(model: ContributableViewsModel) {
|
||||
this.elements = [...model.visibleViewDescriptors];
|
||||
model.onDidAdd(({ viewDescriptor, index }) => this.elements.splice(index, 0, viewDescriptor), null, this.disposables);
|
||||
model.onDidRemove(({ viewDescriptor, index }) => this.elements.splice(index, 1), null, this.disposables);
|
||||
model.onDidAdd(added => added.forEach(({ viewDescriptor, index }) => this.elements.splice(index, 0, viewDescriptor)), null, this.disposables);
|
||||
model.onDidRemove(removed => removed.sort((a, b) => b.index - a.index).forEach(({ index }) => this.elements.splice(index, 1)), null, this.disposables);
|
||||
model.onDidMove(({ from, to }) => move(this.elements, from.index, to.index), null, this.disposables);
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ suite('ContributableViewsModel', () => {
|
||||
let contextKeyService: IContextKeyService;
|
||||
|
||||
setup(() => {
|
||||
const configurationService = new SimpleConfigurationService();
|
||||
const configurationService = new TestConfigurationService();
|
||||
contextKeyService = new ContextKeyService(configurationService);
|
||||
});
|
||||
|
||||
@@ -44,12 +45,12 @@ suite('ContributableViewsModel', () => {
|
||||
});
|
||||
|
||||
test('empty model', function () {
|
||||
const model = new ContributableViewsModel(location, contextKeyService);
|
||||
const model = new ContributableViewsModel(container, contextKeyService);
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
});
|
||||
|
||||
test('register/unregister', function () {
|
||||
const model = new ContributableViewsModel(location, contextKeyService);
|
||||
const model = new ContributableViewsModel(container, contextKeyService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
@@ -58,7 +59,7 @@ suite('ContributableViewsModel', () => {
|
||||
const viewDescriptor: IViewDescriptor = {
|
||||
id: 'view1',
|
||||
ctor: null,
|
||||
location,
|
||||
container,
|
||||
name: 'Test View 1'
|
||||
};
|
||||
|
||||
@@ -69,14 +70,14 @@ suite('ContributableViewsModel', () => {
|
||||
assert.deepEqual(model.visibleViewDescriptors[0], viewDescriptor);
|
||||
assert.deepEqual(seq.elements[0], viewDescriptor);
|
||||
|
||||
ViewsRegistry.deregisterViews(['view1'], location);
|
||||
ViewsRegistry.deregisterViews(['view1'], container);
|
||||
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
assert.equal(seq.elements.length, 0);
|
||||
});
|
||||
|
||||
test('when contexts', async function () {
|
||||
const model = new ContributableViewsModel(location, contextKeyService);
|
||||
const model = new ContributableViewsModel(container, contextKeyService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
assert.equal(model.visibleViewDescriptors.length, 0);
|
||||
@@ -85,7 +86,7 @@ suite('ContributableViewsModel', () => {
|
||||
const viewDescriptor: IViewDescriptor = {
|
||||
id: 'view1',
|
||||
ctor: null,
|
||||
location,
|
||||
container,
|
||||
name: 'Test View 1',
|
||||
when: ContextKeyExpr.equals('showview1', true)
|
||||
};
|
||||
@@ -110,7 +111,7 @@ suite('ContributableViewsModel', () => {
|
||||
assert.equal(model.visibleViewDescriptors.length, 0, 'view should disappear');
|
||||
assert.equal(seq.elements.length, 0);
|
||||
|
||||
ViewsRegistry.deregisterViews(['view1'], location);
|
||||
ViewsRegistry.deregisterViews(['view1'], container);
|
||||
assert.equal(model.visibleViewDescriptors.length, 0, 'view should not be there anymore');
|
||||
assert.equal(seq.elements.length, 0);
|
||||
|
||||
@@ -121,11 +122,11 @@ suite('ContributableViewsModel', () => {
|
||||
});
|
||||
|
||||
test('when contexts - multiple', async function () {
|
||||
const model = new ContributableViewsModel(location, contextKeyService);
|
||||
const model = new ContributableViewsModel(container, contextKeyService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, location, name: 'Test View 1' };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, location, name: 'Test View 2', when: ContextKeyExpr.equals('showview2', true) };
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, container, name: 'Test View 1' };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, container, name: 'Test View 2', when: ContextKeyExpr.equals('showview2', true) };
|
||||
|
||||
ViewsRegistry.registerViews([view1, view2]);
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view1], 'only view1 should be visible');
|
||||
@@ -140,15 +141,15 @@ suite('ContributableViewsModel', () => {
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view1, view2], 'both views should be visible');
|
||||
assert.deepEqual(seq.elements, [view1, view2], 'both views should be visible');
|
||||
|
||||
ViewsRegistry.deregisterViews([view1.id, view2.id], location);
|
||||
ViewsRegistry.deregisterViews([view1.id, view2.id], container);
|
||||
});
|
||||
|
||||
test('when contexts - multiple 2', async function () {
|
||||
const model = new ContributableViewsModel(location, contextKeyService);
|
||||
const model = new ContributableViewsModel(container, contextKeyService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, location, name: 'Test View 1', when: ContextKeyExpr.equals('showview1', true) };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, location, name: 'Test View 2' };
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, container, name: 'Test View 1', when: ContextKeyExpr.equals('showview1', true) };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, container, name: 'Test View 2' };
|
||||
|
||||
ViewsRegistry.registerViews([view1, view2]);
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view2], 'only view2 should be visible');
|
||||
@@ -163,16 +164,16 @@ suite('ContributableViewsModel', () => {
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view1, view2], 'both views should be visible');
|
||||
assert.deepEqual(seq.elements, [view1, view2], 'both views should be visible');
|
||||
|
||||
ViewsRegistry.deregisterViews([view1.id, view2.id], location);
|
||||
ViewsRegistry.deregisterViews([view1.id, view2.id], container);
|
||||
});
|
||||
|
||||
test('setVisible', function () {
|
||||
const model = new ContributableViewsModel(location, contextKeyService);
|
||||
const model = new ContributableViewsModel(container, contextKeyService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, location, name: 'Test View 1', canToggleVisibility: true };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, location, name: 'Test View 2', canToggleVisibility: true };
|
||||
const view3: IViewDescriptor = { id: 'view3', ctor: null, location, name: 'Test View 3', canToggleVisibility: true };
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, container, name: 'Test View 1', canToggleVisibility: true };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, container, name: 'Test View 2', canToggleVisibility: true };
|
||||
const view3: IViewDescriptor = { id: 'view3', ctor: null, container, name: 'Test View 3', canToggleVisibility: true };
|
||||
|
||||
ViewsRegistry.registerViews([view1, view2, view3]);
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view1, view2, view3]);
|
||||
@@ -206,18 +207,18 @@ suite('ContributableViewsModel', () => {
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view1, view2, view3], 'view2 should show');
|
||||
assert.deepEqual(seq.elements, [view1, view2, view3]);
|
||||
|
||||
ViewsRegistry.deregisterViews([view1.id, view2.id, view3.id], location);
|
||||
ViewsRegistry.deregisterViews([view1.id, view2.id, view3.id], container);
|
||||
assert.deepEqual(model.visibleViewDescriptors, []);
|
||||
assert.deepEqual(seq.elements, []);
|
||||
});
|
||||
|
||||
test('move', function () {
|
||||
const model = new ContributableViewsModel(location, contextKeyService);
|
||||
const model = new ContributableViewsModel(container, contextKeyService);
|
||||
const seq = new ViewDescriptorSequence(model);
|
||||
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, location, name: 'Test View 1' };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, location, name: 'Test View 2' };
|
||||
const view3: IViewDescriptor = { id: 'view3', ctor: null, location, name: 'Test View 3' };
|
||||
const view1: IViewDescriptor = { id: 'view1', ctor: null, container, name: 'Test View 1' };
|
||||
const view2: IViewDescriptor = { id: 'view2', ctor: null, container, name: 'Test View 2' };
|
||||
const view3: IViewDescriptor = { id: 'view3', ctor: null, container, name: 'Test View 3' };
|
||||
|
||||
ViewsRegistry.registerViews([view1, view2, view3]);
|
||||
assert.deepEqual(model.visibleViewDescriptors, [view1, view2, view3], 'model views should be OK');
|
||||
@@ -26,10 +26,6 @@ export class TestQuickOpenService implements IQuickOpenService {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
input(options?: any, token?: any): Promise {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
}
|
||||
|
||||
@@ -59,11 +55,9 @@ export class TestQuickOpenService implements IQuickOpenService {
|
||||
public navigate(): void { }
|
||||
}
|
||||
|
||||
suite('Workbench QuickOpen', () => {
|
||||
suite('QuickOpen', () => {
|
||||
|
||||
class TestHandler extends QuickOpenHandler {
|
||||
|
||||
}
|
||||
class TestHandler extends QuickOpenHandler { }
|
||||
|
||||
test('QuickOpen Handler and Registry', () => {
|
||||
let registry = (Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen));
|
||||
|
||||
@@ -10,7 +10,7 @@ import * as Platform from 'vs/platform/registry/common/platform';
|
||||
import { ViewletDescriptor, Extensions, Viewlet, ViewletRegistry } from 'vs/workbench/browser/viewlet';
|
||||
import * as Types from 'vs/base/common/types';
|
||||
|
||||
suite('Workbench Viewlet', () => {
|
||||
suite('Viewlets', () => {
|
||||
|
||||
class TestViewlet extends Viewlet {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestSe
|
||||
import { DataUriEditorInput } from 'vs/workbench/common/editor/dataUriEditorInput';
|
||||
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
|
||||
|
||||
suite('Workbench - DataUriEditorInput', () => {
|
||||
suite('DataUriEditorInput', () => {
|
||||
|
||||
let instantiationService: IInstantiationService;
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { EditorInput, toResource, EditorViewStateMemento } from 'vs/workbench/common/editor';
|
||||
import { EditorInput, toResource } from 'vs/workbench/common/editor';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { IEditorModel, Position } from 'vs/platform/editor/common/editor';
|
||||
import { IEditorModel } from 'vs/platform/editor/common/editor';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -35,12 +35,12 @@ class FileEditorInput extends EditorInput {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
resolve(refresh?: boolean): TPromise<IEditorModel> {
|
||||
resolve(): TPromise<IEditorModel> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench - Editor', () => {
|
||||
suite('Workbench editor', () => {
|
||||
|
||||
let instantiationService: IInstantiationService;
|
||||
let accessor: ServiceAccessor;
|
||||
@@ -86,129 +86,4 @@ suite('Workbench - Editor', () => {
|
||||
assert.equal(toResource(file, { supportSideBySide: true, filter: Schemas.file }).toString(), file.getResource().toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: true, filter: [Schemas.file, Schemas.untitled] }).toString(), file.getResource().toString());
|
||||
});
|
||||
|
||||
test('EditorViewStateMemento - basics', function () {
|
||||
interface TestViewState {
|
||||
line: number;
|
||||
}
|
||||
|
||||
const rawMemento = Object.create(null);
|
||||
let memento = new EditorViewStateMemento<TestViewState>(rawMemento, 'key', 3);
|
||||
|
||||
let res = memento.loadState(URI.file('/A'), Position.ONE);
|
||||
assert.ok(!res);
|
||||
|
||||
memento.saveState(URI.file('/A'), Position.ONE, { line: 3 });
|
||||
res = memento.loadState(URI.file('/A'), Position.ONE);
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 3);
|
||||
|
||||
memento.saveState(URI.file('/A'), Position.TWO, { line: 5 });
|
||||
res = memento.loadState(URI.file('/A'), Position.TWO);
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 5);
|
||||
|
||||
// Ensure capped at 3 elements
|
||||
memento.saveState(URI.file('/B'), Position.ONE, { line: 1 });
|
||||
memento.saveState(URI.file('/C'), Position.ONE, { line: 1 });
|
||||
memento.saveState(URI.file('/D'), Position.ONE, { line: 1 });
|
||||
memento.saveState(URI.file('/E'), Position.ONE, { line: 1 });
|
||||
|
||||
assert.ok(!memento.loadState(URI.file('/A'), Position.ONE));
|
||||
assert.ok(!memento.loadState(URI.file('/B'), Position.ONE));
|
||||
assert.ok(memento.loadState(URI.file('/C'), Position.ONE));
|
||||
assert.ok(memento.loadState(URI.file('/D'), Position.ONE));
|
||||
assert.ok(memento.loadState(URI.file('/E'), Position.ONE));
|
||||
|
||||
memento.save();
|
||||
|
||||
memento = new EditorViewStateMemento(rawMemento, 'key', 3);
|
||||
assert.ok(memento.loadState(URI.file('/C'), Position.ONE));
|
||||
assert.ok(memento.loadState(URI.file('/D'), Position.ONE));
|
||||
assert.ok(memento.loadState(URI.file('/E'), Position.ONE));
|
||||
|
||||
memento.clearState(URI.file('/C'));
|
||||
memento.clearState(URI.file('/E'));
|
||||
|
||||
assert.ok(!memento.loadState(URI.file('/C'), Position.ONE));
|
||||
assert.ok(memento.loadState(URI.file('/D'), Position.ONE));
|
||||
assert.ok(!memento.loadState(URI.file('/E'), Position.ONE));
|
||||
});
|
||||
|
||||
test('EditorViewStateMemento - use with editor input', function () {
|
||||
interface TestViewState {
|
||||
line: number;
|
||||
}
|
||||
|
||||
class TestEditorInput extends EditorInput {
|
||||
constructor(private resource: URI, private id = 'testEditorInput') {
|
||||
super();
|
||||
}
|
||||
public getTypeId() { return 'testEditorInput'; }
|
||||
public resolve(): TPromise<IEditorModel> { return null; }
|
||||
|
||||
public matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
}
|
||||
|
||||
public getResource(): URI {
|
||||
return this.resource;
|
||||
}
|
||||
}
|
||||
|
||||
const rawMemento = Object.create(null);
|
||||
let memento = new EditorViewStateMemento<TestViewState>(rawMemento, 'key', 3);
|
||||
|
||||
const testInputA = new TestEditorInput(URI.file('/A'));
|
||||
|
||||
let res = memento.loadState(testInputA, Position.ONE);
|
||||
assert.ok(!res);
|
||||
|
||||
memento.saveState(testInputA, Position.ONE, { line: 3 });
|
||||
res = memento.loadState(testInputA, Position.ONE);
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 3);
|
||||
|
||||
// State removed when input gets disposed
|
||||
testInputA.dispose();
|
||||
res = memento.loadState(testInputA, Position.ONE);
|
||||
assert.ok(!res);
|
||||
});
|
||||
|
||||
test('EditorViewStateMemento - migration', function () {
|
||||
interface TestViewState {
|
||||
line: number;
|
||||
}
|
||||
|
||||
const rawMemento = {
|
||||
'key': {
|
||||
[URI.file('/A').toString()]: {
|
||||
0: {
|
||||
line: 5
|
||||
}
|
||||
},
|
||||
[URI.file('/B').toString()]: {
|
||||
0: {
|
||||
line: 1
|
||||
},
|
||||
1: {
|
||||
line: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let memento = new EditorViewStateMemento<TestViewState>(rawMemento, 'key', 3);
|
||||
|
||||
let res = memento.loadState(URI.file('/A'), Position.ONE);
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 5);
|
||||
|
||||
res = memento.loadState(URI.file('/B'), Position.ONE);
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 1);
|
||||
|
||||
res = memento.loadState(URI.file('/B'), Position.TWO);
|
||||
assert.ok(res);
|
||||
assert.equal(res.line, 2);
|
||||
});
|
||||
});
|
||||
@@ -29,7 +29,7 @@ class ServiceAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench - EditorModel', () => {
|
||||
suite('Workbench editor model', () => {
|
||||
let instantiationService: IInstantiationService;
|
||||
let accessor: ServiceAccessor;
|
||||
|
||||
@@ -55,7 +55,7 @@ suite('Workbench - EditorModel', () => {
|
||||
let otherInput = instantiationService.createInstance(ResourceEditorInput, 'name2', 'description', URI.from({ scheme: 'test', authority: null, path: 'thePath' }));
|
||||
let diffInput = new DiffEditorInput('name', 'description', input, otherInput);
|
||||
|
||||
return diffInput.resolve(true).then((model: any) => {
|
||||
return diffInput.resolve().then((model: any) => {
|
||||
assert(model);
|
||||
assert(model instanceof TextDiffEditorModel);
|
||||
|
||||
@@ -63,7 +63,7 @@ suite('Workbench - EditorModel', () => {
|
||||
assert(diffEditorModel.original);
|
||||
assert(diffEditorModel.modified);
|
||||
|
||||
return diffInput.resolve(true).then((model: any) => {
|
||||
return diffInput.resolve().then((model: any) => {
|
||||
assert(model.isResolved());
|
||||
|
||||
assert(diffEditorModel !== model.textDiffEditorModel);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,16 +10,11 @@ import { EditorInput } from 'vs/workbench/common/editor';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
|
||||
class MyEditorInput extends EditorInput {
|
||||
public getTypeId(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public resolve(refresh?: boolean): any {
|
||||
return null;
|
||||
}
|
||||
getTypeId(): string { return ''; }
|
||||
resolve(): any { return null; }
|
||||
}
|
||||
|
||||
suite('Workbench - EditorInput', () => {
|
||||
suite('Workbench editor input', () => {
|
||||
|
||||
test('EditorInput', function () {
|
||||
let counter = 0;
|
||||
|
||||
@@ -24,9 +24,13 @@ class MyTextEditorModel extends BaseTextEditorModel {
|
||||
public createTextEditorModel(value: ITextBufferFactory, resource?: URI, modeId?: string) {
|
||||
return super.createTextEditorModel(value, resource, modeId);
|
||||
}
|
||||
|
||||
isReadonly(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench - EditorModel', () => {
|
||||
suite('Workbench editor model', () => {
|
||||
|
||||
let instantiationService: TestInstantiationService;
|
||||
let modeService: IModeService;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import * as assert from 'assert';
|
||||
import { EditorOptions, TextEditorOptions } from 'vs/workbench/common/editor';
|
||||
|
||||
suite('Workbench - EditorOptions', () => {
|
||||
suite('Workbench editor options', () => {
|
||||
|
||||
test('EditorOptions', function () {
|
||||
let options = new EditorOptions();
|
||||
@@ -16,12 +16,12 @@ suite('Workbench - EditorOptions', () => {
|
||||
assert(!options.preserveFocus);
|
||||
options.preserveFocus = true;
|
||||
assert(options.preserveFocus);
|
||||
assert(!options.forceOpen);
|
||||
options.forceOpen = true;
|
||||
assert(options.forceOpen);
|
||||
assert(!options.forceReload);
|
||||
options.forceReload = true;
|
||||
assert(options.forceReload);
|
||||
|
||||
options = new EditorOptions();
|
||||
options.forceOpen = true;
|
||||
options.forceReload = true;
|
||||
});
|
||||
|
||||
test('TextEditorOptions', function () {
|
||||
@@ -35,7 +35,7 @@ suite('Workbench - EditorOptions', () => {
|
||||
otherOptions.selection(1, 1, 2, 2);
|
||||
|
||||
options = new TextEditorOptions();
|
||||
options.forceOpen = true;
|
||||
options.forceReload = true;
|
||||
options.selection(1, 1, 2, 2);
|
||||
});
|
||||
});
|
||||
@@ -23,7 +23,7 @@ class ServiceAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench - ResourceEditorInput', () => {
|
||||
suite('Workbench resource editor input', () => {
|
||||
|
||||
let instantiationService: IInstantiationService;
|
||||
let accessor: ServiceAccessor;
|
||||
|
||||
@@ -20,14 +20,8 @@ import { snapshotToString } from 'vs/platform/files/common/files';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
export class TestUntitledEditorService extends UntitledEditorService {
|
||||
|
||||
public get(resource: URI): UntitledEditorInput {
|
||||
return super.get(resource);
|
||||
}
|
||||
|
||||
public getAll(resources?: URI[]): UntitledEditorInput[] {
|
||||
return super.getAll(resources);
|
||||
}
|
||||
get(resource: URI): UntitledEditorInput { return super.get(resource); }
|
||||
getAll(resources?: URI[]): UntitledEditorInput[] { return super.getAll(resources); }
|
||||
}
|
||||
|
||||
class ServiceAccessor {
|
||||
@@ -38,7 +32,7 @@ class ServiceAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench - Untitled Editor', () => {
|
||||
suite('Workbench untitled editors', () => {
|
||||
|
||||
let instantiationService: IInstantiationService;
|
||||
let accessor: ServiceAccessor;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Memento, Scope } from 'vs/workbench/common/memento';
|
||||
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
|
||||
suite('Workbench Memento', () => {
|
||||
suite('Memento', () => {
|
||||
let context: Scope = undefined;
|
||||
let storage: StorageService;
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { originalFSPath } from 'vs/workbench/api/node/extHost.api.impl';
|
||||
|
||||
suite('ExtHost API', function () {
|
||||
test('issue #51387: originalFSPath', function () {
|
||||
assert.equal(originalFSPath(URI.file('C:\\test')).charAt(0), 'C');
|
||||
assert.equal(originalFSPath(URI.file('c:\\test')).charAt(0), 'c');
|
||||
|
||||
assert.equal(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('C:\\test'))))).charAt(0), 'C');
|
||||
assert.equal(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('c:\\test'))))).charAt(0), 'c');
|
||||
});
|
||||
});
|
||||
@@ -33,9 +33,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import 'vs/workbench/parts/search/electron-browser/search.contribution';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { ExtHostTask } from 'vs/workbench/api/node/extHostTask';
|
||||
|
||||
const defaultSelector = { scheme: 'far' };
|
||||
const model: ITextModel = EditorModel.createFromString(
|
||||
@@ -52,8 +49,6 @@ let rpcProtocol: TestRPCProtocol;
|
||||
let extHost: ExtHostLanguageFeatures;
|
||||
let mainThread: MainThreadLanguageFeatures;
|
||||
let commands: ExtHostCommands;
|
||||
let task: ExtHostTask;
|
||||
let workspace: ExtHostWorkspace;
|
||||
let disposables: vscode.Disposable[] = [];
|
||||
let originalErrorHandler: (e: any) => any;
|
||||
|
||||
@@ -71,14 +66,14 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
rpcProtocol = new TestRPCProtocol();
|
||||
instantiationService.stub(IHeapService, {
|
||||
_serviceBrand: undefined,
|
||||
trackRecursive(args) {
|
||||
trackRecursive(args: any) {
|
||||
// nothing
|
||||
return args;
|
||||
}
|
||||
});
|
||||
instantiationService.stub(ICommandService, {
|
||||
_serviceBrand: undefined,
|
||||
executeCommand(id, args): any {
|
||||
executeCommand(id: string, args: any): any {
|
||||
if (!CommandsRegistry.getCommands()[id]) {
|
||||
return TPromise.wrapError(new Error(id + ' NOT known'));
|
||||
}
|
||||
@@ -120,16 +115,14 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
const heapService = new ExtHostHeapService();
|
||||
|
||||
commands = new ExtHostCommands(rpcProtocol, heapService, new NullLogService());
|
||||
workspace = new ExtHostWorkspace(rpcProtocol, { id: generateUuid(), name: 'Test', folders: [] }, new NullLogService());
|
||||
task = new ExtHostTask(rpcProtocol, workspace);
|
||||
rpcProtocol.set(ExtHostContext.ExtHostCommands, commands);
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, rpcProtocol));
|
||||
ExtHostApiCommands.register(commands, task);
|
||||
ExtHostApiCommands.register(commands);
|
||||
|
||||
const diagnostics = new ExtHostDiagnostics(rpcProtocol);
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, diagnostics);
|
||||
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, heapService, diagnostics);
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, heapService, diagnostics, new NullLogService());
|
||||
rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, extHost);
|
||||
|
||||
mainThread = rpcProtocol.set(MainContext.MainThreadLanguageFeatures, inst.createInstance(MainThreadLanguageFeatures, rpcProtocol));
|
||||
@@ -339,6 +332,8 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
return commands.executeCommand<vscode.SymbolInformation[]>('vscode.executeDocumentSymbolProvider', model.uri).then(values => {
|
||||
assert.equal(values.length, 2);
|
||||
let [first, second] = values;
|
||||
assert.ok(first instanceof types.SymbolInformation);
|
||||
assert.ok(second instanceof types.SymbolInformation);
|
||||
assert.equal(first.name, 'testing2');
|
||||
assert.equal(second.name, 'testing1');
|
||||
});
|
||||
@@ -455,6 +450,38 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
|
||||
});
|
||||
|
||||
test('"vscode.executeCompletionItemProvider" doesnot return a preselect field #53749', async function () {
|
||||
disposables.push(extHost.registerCompletionItemProvider(defaultSelector, <vscode.CompletionItemProvider>{
|
||||
provideCompletionItems(): any {
|
||||
let a = new types.CompletionItem('item1');
|
||||
a.preselect = true;
|
||||
let b = new types.CompletionItem('item2');
|
||||
let c = new types.CompletionItem('item3');
|
||||
c.preselect = true;
|
||||
let d = new types.CompletionItem('item4');
|
||||
return new types.CompletionList([a, b, c, d], false);
|
||||
}
|
||||
}, []));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
|
||||
let list = await commands.executeCommand<vscode.CompletionList>(
|
||||
'vscode.executeCompletionItemProvider',
|
||||
model.uri,
|
||||
new types.Position(0, 4),
|
||||
undefined
|
||||
);
|
||||
|
||||
assert.ok(list instanceof types.CompletionList);
|
||||
assert.equal(list.items.length, 4);
|
||||
|
||||
let [a, b, c, d] = list.items;
|
||||
assert.equal(a.preselect, true);
|
||||
assert.equal(b.preselect, undefined);
|
||||
assert.equal(c.preselect, true);
|
||||
assert.equal(d.preselect, undefined);
|
||||
});
|
||||
|
||||
// --- quickfix
|
||||
|
||||
test('QuickFix, back and forth', function () {
|
||||
@@ -640,4 +667,20 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('"TypeError: e.onCancellationRequested is not a function" calling hover provider in Insiders #54174', function () {
|
||||
|
||||
disposables.push(extHost.registerHoverProvider(defaultSelector, <vscode.HoverProvider>{
|
||||
provideHover(): any {
|
||||
return new types.Hover('fofofofo');
|
||||
}
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return commands.executeCommand<vscode.Hover[]>('vscode.executeHoverProvider', model.uri, new types.Position(1, 1)).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
assert.equal(value[0].contents.length, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import URI, { UriComponents } from 'vs/base/common/uri';
|
||||
import { DiagnosticCollection } from 'vs/workbench/api/node/extHostDiagnostics';
|
||||
import { DiagnosticCollection, ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
|
||||
import { Diagnostic, DiagnosticSeverity, Range, DiagnosticRelatedInformation, Location } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { MainThreadDiagnosticsShape } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { MainThreadDiagnosticsShape, IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { Emitter, toPromise } from 'vs/base/common/event';
|
||||
@@ -27,7 +27,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
|
||||
test('disposeCheck', function () {
|
||||
|
||||
const collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
|
||||
const collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
|
||||
|
||||
collection.dispose();
|
||||
collection.dispose(); // that's OK
|
||||
@@ -44,13 +44,13 @@ suite('ExtHostDiagnostics', () => {
|
||||
|
||||
|
||||
test('diagnostic collection, forEach, clear, has', function () {
|
||||
let collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
|
||||
let collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
|
||||
assert.equal(collection.name, 'test');
|
||||
collection.dispose();
|
||||
assert.throws(() => collection.name);
|
||||
|
||||
let c = 0;
|
||||
collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
|
||||
collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
|
||||
collection.forEach(() => c++);
|
||||
assert.equal(c, 0);
|
||||
|
||||
@@ -87,7 +87,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
});
|
||||
|
||||
test('diagnostic collection, immutable read', function () {
|
||||
let collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
|
||||
let collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
|
||||
collection.set(URI.parse('foo:bar'), [
|
||||
new Diagnostic(new Range(0, 0, 1, 1), 'message-1'),
|
||||
new Diagnostic(new Range(0, 0, 1, 1), 'message-2')
|
||||
@@ -112,7 +112,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
|
||||
|
||||
test('diagnostics collection, set with dupliclated tuples', function () {
|
||||
let collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
|
||||
let collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
|
||||
let uri = URI.parse('sc:hightower');
|
||||
collection.set([
|
||||
[uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-1')]],
|
||||
@@ -163,7 +163,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
test('diagnostics collection, set tuple overrides, #11547', function () {
|
||||
|
||||
let lastEntries: [UriComponents, IMarkerData[]][];
|
||||
let collection = new DiagnosticCollection('test', new class extends DiagnosticsShape {
|
||||
let collection = new DiagnosticCollection('test', 'test', 100, new class extends DiagnosticsShape {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
|
||||
lastEntries = entries;
|
||||
return super.$changeMany(owner, entries);
|
||||
@@ -192,7 +192,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
|
||||
test('diagnostics collection, tuples and undefined (small array), #15585', function () {
|
||||
|
||||
const collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
|
||||
const collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
|
||||
let uri = URI.parse('sc:hightower');
|
||||
let uri2 = URI.parse('sc:nomad');
|
||||
let diag = new Diagnostic(new Range(0, 0, 0, 1), 'ffff');
|
||||
@@ -213,7 +213,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
|
||||
test('diagnostics collection, tuples and undefined (large array), #15585', function () {
|
||||
|
||||
const collection = new DiagnosticCollection('test', new DiagnosticsShape(), new Emitter());
|
||||
const collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
|
||||
const tuples: [URI, Diagnostic[]][] = [];
|
||||
|
||||
for (let i = 0; i < 500; i++) {
|
||||
@@ -237,7 +237,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
test('diagnostic capping', function () {
|
||||
|
||||
let lastEntries: [UriComponents, IMarkerData[]][];
|
||||
let collection = new DiagnosticCollection('test', new class extends DiagnosticsShape {
|
||||
let collection = new DiagnosticCollection('test', 'test', 250, new class extends DiagnosticsShape {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
|
||||
lastEntries = entries;
|
||||
return super.$changeMany(owner, entries);
|
||||
@@ -258,12 +258,12 @@ suite('ExtHostDiagnostics', () => {
|
||||
assert.equal(lastEntries[0][1].length, 251);
|
||||
assert.equal(lastEntries[0][1][0].severity, MarkerSeverity.Error);
|
||||
assert.equal(lastEntries[0][1][200].severity, MarkerSeverity.Warning);
|
||||
assert.equal(lastEntries[0][1][250].severity, MarkerSeverity.Error);
|
||||
assert.equal(lastEntries[0][1][250].severity, MarkerSeverity.Info);
|
||||
});
|
||||
|
||||
test('diagnostic eventing', async function () {
|
||||
let emitter = new Emitter<(string | URI)[]>();
|
||||
let collection = new DiagnosticCollection('ddd', new DiagnosticsShape(), emitter);
|
||||
let collection = new DiagnosticCollection('ddd', 'test', 100, new DiagnosticsShape(), emitter);
|
||||
|
||||
let diag1 = new Diagnostic(new Range(1, 1, 2, 3), 'diag1');
|
||||
let diag2 = new Diagnostic(new Range(1, 1, 2, 3), 'diag2');
|
||||
@@ -299,9 +299,32 @@ suite('ExtHostDiagnostics', () => {
|
||||
await p;
|
||||
});
|
||||
|
||||
test('vscode.languages.onDidChangeDiagnostics Does Not Provide Document URI #49582', async function () {
|
||||
let emitter = new Emitter<(string | URI)[]>();
|
||||
let collection = new DiagnosticCollection('ddd', 'test', 100, new DiagnosticsShape(), emitter);
|
||||
|
||||
let diag1 = new Diagnostic(new Range(1, 1, 2, 3), 'diag1');
|
||||
|
||||
// delete
|
||||
collection.set(URI.parse('aa:bb'), [diag1]);
|
||||
let p = toPromise(emitter.event).then(e => {
|
||||
assert.equal(e[0].toString(), 'aa:bb');
|
||||
});
|
||||
collection.delete(URI.parse('aa:bb'));
|
||||
await p;
|
||||
|
||||
// set->undefined (as delete)
|
||||
collection.set(URI.parse('aa:bb'), [diag1]);
|
||||
p = toPromise(emitter.event).then(e => {
|
||||
assert.equal(e[0].toString(), 'aa:bb');
|
||||
});
|
||||
collection.set(URI.parse('aa:bb'), undefined);
|
||||
await p;
|
||||
});
|
||||
|
||||
test('diagnostics with related information', function (done) {
|
||||
|
||||
let collection = new DiagnosticCollection('ddd', new class extends DiagnosticsShape {
|
||||
let collection = new DiagnosticCollection('ddd', 'test', 100, new class extends DiagnosticsShape {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]) {
|
||||
|
||||
let [[, data]] = entries;
|
||||
@@ -324,4 +347,33 @@ suite('ExtHostDiagnostics', () => {
|
||||
|
||||
collection.set(URI.parse('aa:bb'), [diag]);
|
||||
});
|
||||
|
||||
test('vscode.languages.getDiagnostics appears to return old diagnostics in some circumstances #54359', function () {
|
||||
const ownerHistory: string[] = [];
|
||||
const diags = new ExtHostDiagnostics(new class implements IMainContext {
|
||||
getProxy(id: any): any {
|
||||
return new class DiagnosticsShape {
|
||||
$clear(owner: string): void {
|
||||
ownerHistory.push(owner);
|
||||
}
|
||||
};
|
||||
}
|
||||
set(): any {
|
||||
return null;
|
||||
}
|
||||
assertRegistered(): void {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
let collection1 = diags.createDiagnosticCollection('foo');
|
||||
let collection2 = diags.createDiagnosticCollection('foo'); // warns, uses a different owner
|
||||
|
||||
collection1.clear();
|
||||
collection2.clear();
|
||||
|
||||
assert.equal(ownerHistory.length, 2);
|
||||
assert.equal(ownerHistory[0], 'foo');
|
||||
assert.equal(ownerHistory[1], 'foo0');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,8 +33,9 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
publisher: 'vscode',
|
||||
enableProposedApi: false,
|
||||
engines: undefined,
|
||||
extensionFolderPath: undefined,
|
||||
extensionLocation: undefined,
|
||||
isBuiltin: false,
|
||||
isUnderDevelopment: false,
|
||||
version: undefined
|
||||
};
|
||||
|
||||
@@ -87,7 +88,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
sub.dispose();
|
||||
|
||||
assert.ok(event);
|
||||
assert.throws(() => event.document = null);
|
||||
assert.throws(() => { event.document = null; });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -167,12 +168,12 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
let callCount = 0;
|
||||
let sub1 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
|
||||
callCount += 1;
|
||||
event.waitUntil(timeout(17));
|
||||
event.waitUntil(timeout(1));
|
||||
});
|
||||
|
||||
let sub2 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
|
||||
callCount += 1;
|
||||
event.waitUntil(timeout(17));
|
||||
event.waitUntil(timeout(170));
|
||||
});
|
||||
|
||||
let sub3 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
|
||||
|
||||
@@ -6,18 +6,25 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ExtHostFileSystemEventService } from 'vs/workbench/api/node/extHostFileSystemEventService';
|
||||
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
|
||||
suite('ExtHostFileSystemEventService', () => {
|
||||
|
||||
|
||||
test('FileSystemWatcher ignore events properties are reversed #26851', function () {
|
||||
|
||||
const watcher1 = new ExtHostFileSystemEventService().createFileSystemWatcher('**/somethingInteresting', false, false, false);
|
||||
const protocol: IMainContext = {
|
||||
getProxy: () => { return undefined; },
|
||||
set: undefined,
|
||||
assertRegistered: undefined
|
||||
};
|
||||
|
||||
const watcher1 = new ExtHostFileSystemEventService(protocol, undefined).createFileSystemWatcher('**/somethingInteresting', false, false, false);
|
||||
assert.equal(watcher1.ignoreChangeEvents, false);
|
||||
assert.equal(watcher1.ignoreCreateEvents, false);
|
||||
assert.equal(watcher1.ignoreDeleteEvents, false);
|
||||
|
||||
const watcher2 = new ExtHostFileSystemEventService().createFileSystemWatcher('**/somethingBoring', true, true, true);
|
||||
const watcher2 = new ExtHostFileSystemEventService(protocol, undefined).createFileSystemWatcher('**/somethingBoring', true, true, true);
|
||||
assert.equal(watcher2.ignoreChangeEvents, true);
|
||||
assert.equal(watcher2.ignoreCreateEvents, true);
|
||||
assert.equal(watcher2.ignoreDeleteEvents, true);
|
||||
|
||||
@@ -26,7 +26,7 @@ import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/node/extHostDocumen
|
||||
import { getDocumentSymbols } from 'vs/editor/contrib/quickOpen/quickOpen';
|
||||
import { DocumentSymbolProviderRegistry, DocumentHighlightKind, Hover, ResourceTextEdit } from 'vs/editor/common/modes';
|
||||
import { getCodeLensData } from 'vs/editor/contrib/codelens/codelens';
|
||||
import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefinitionsAtPosition } from 'vs/editor/contrib/goToDeclaration/goToDeclaration';
|
||||
import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefinitionsAtPosition } from 'vs/editor/contrib/goToDefinition/goToDefinition';
|
||||
import { getHover } from 'vs/editor/contrib/hover/getHover';
|
||||
import { getOccurrencesAtPosition } from 'vs/editor/contrib/wordHighlighter/wordHighlighter';
|
||||
import { provideReferences } from 'vs/editor/contrib/referenceSearch/referenceSearch';
|
||||
@@ -46,6 +46,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ITextModel, EndOfLineSequence } from 'vs/editor/common/model';
|
||||
import { getColors } from 'vs/editor/contrib/colorPicker/color';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
const defaultSelector = { scheme: 'far' };
|
||||
const model: ITextModel = EditorModel.createFromString(
|
||||
@@ -77,7 +78,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
instantiationService.stub(IMarkerService, MarkerService);
|
||||
instantiationService.stub(IHeapService, {
|
||||
_serviceBrand: undefined,
|
||||
trackRecursive(args) {
|
||||
trackRecursive(args: any) {
|
||||
// nothing
|
||||
return args;
|
||||
}
|
||||
@@ -111,7 +112,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
const diagnostics = new ExtHostDiagnostics(rpcProtocol);
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, diagnostics);
|
||||
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, heapService, diagnostics);
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, heapService, diagnostics, new NullLogService());
|
||||
rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, extHost);
|
||||
|
||||
mainThread = rpcProtocol.set(MainContext.MainThreadLanguageFeatures, inst.createInstance(MainThreadLanguageFeatures, rpcProtocol));
|
||||
@@ -136,7 +137,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
assert.equal(DocumentSymbolProviderRegistry.all(model).length, 0);
|
||||
let d1 = extHost.registerDocumentSymbolProvider(defaultSelector, <vscode.DocumentSymbolProvider>{
|
||||
provideDocumentSymbols() {
|
||||
return [];
|
||||
return <vscode.SymbolInformation[]>[];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -163,7 +164,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return getDocumentSymbols(model).then(value => {
|
||||
assert.equal(value.entries.length, 1);
|
||||
assert.equal(value.length, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -178,11 +179,11 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return getDocumentSymbols(model).then(value => {
|
||||
assert.equal(value.entries.length, 1);
|
||||
assert.equal(value.length, 1);
|
||||
|
||||
let entry = value.entries[0];
|
||||
let entry = value[0];
|
||||
assert.equal(entry.name, 'test');
|
||||
assert.deepEqual(entry.location.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
|
||||
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -203,7 +204,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return getCodeLensData(model).then(value => {
|
||||
return getCodeLensData(model, CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
});
|
||||
});
|
||||
@@ -224,7 +225,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return getCodeLensData(model).then(value => {
|
||||
return getCodeLensData(model, CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
let data = value[0];
|
||||
|
||||
@@ -248,7 +249,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return getCodeLensData(model).then(value => {
|
||||
return getCodeLensData(model, CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
|
||||
let data = value[0];
|
||||
@@ -403,7 +404,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
getHover(model, new EditorPosition(1, 1)).then(value => {
|
||||
getHover(model, new EditorPosition(1, 1), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
let [entry] = value;
|
||||
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
|
||||
@@ -422,7 +423,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
getHover(model, new EditorPosition(1, 1)).then(value => {
|
||||
getHover(model, new EditorPosition(1, 1), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
let [entry] = value;
|
||||
assert.deepEqual(entry.range, { startLineNumber: 4, startColumn: 1, endLineNumber: 9, endColumn: 8 });
|
||||
@@ -446,7 +447,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return getHover(model, new EditorPosition(1, 1)).then(value => {
|
||||
return getHover(model, new EditorPosition(1, 1), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 2);
|
||||
let [first, second] = value as Hover[];
|
||||
assert.equal(first.contents[0].value, 'registered second');
|
||||
@@ -471,7 +472,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
getHover(model, new EditorPosition(1, 1)).then(value => {
|
||||
getHover(model, new EditorPosition(1, 1), CancellationToken.None).then(value => {
|
||||
|
||||
assert.equal(value.length, 1);
|
||||
});
|
||||
@@ -490,7 +491,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return getOccurrencesAtPosition(model, new EditorPosition(1, 2)).then(value => {
|
||||
return getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
let [entry] = value;
|
||||
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
|
||||
@@ -514,7 +515,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return getOccurrencesAtPosition(model, new EditorPosition(1, 2)).then(value => {
|
||||
return getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
let [entry] = value;
|
||||
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
|
||||
@@ -538,7 +539,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return getOccurrencesAtPosition(model, new EditorPosition(1, 2)).then(value => {
|
||||
return getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
let [entry] = value;
|
||||
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 3 });
|
||||
@@ -563,7 +564,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return getOccurrencesAtPosition(model, new EditorPosition(1, 2)).then(value => {
|
||||
return getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
});
|
||||
});
|
||||
@@ -587,7 +588,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return provideReferences(model, new EditorPosition(1, 2)).then(value => {
|
||||
return provideReferences(model, new EditorPosition(1, 2), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 2);
|
||||
|
||||
let [first, second] = value;
|
||||
@@ -607,7 +608,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return provideReferences(model, new EditorPosition(1, 2)).then(value => {
|
||||
return provideReferences(model, new EditorPosition(1, 2), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
|
||||
let [item] = value;
|
||||
@@ -633,7 +634,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return provideReferences(model, new EditorPosition(1, 2)).then(value => {
|
||||
return provideReferences(model, new EditorPosition(1, 2), CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
});
|
||||
|
||||
@@ -654,7 +655,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return getCodeActions(model, model.getFullModelRange()).then(value => {
|
||||
return getCodeActions(model, model.getFullModelRange(), undefined).then(value => {
|
||||
assert.equal(value.length, 2);
|
||||
|
||||
const [first, second] = value;
|
||||
@@ -681,7 +682,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return getCodeActions(model, model.getFullModelRange()).then(value => {
|
||||
return getCodeActions(model, model.getFullModelRange(), undefined).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
|
||||
const [first] = value;
|
||||
@@ -707,7 +708,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return getCodeActions(model, model.getFullModelRange()).then(value => {
|
||||
return getCodeActions(model, model.getFullModelRange(), undefined).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
});
|
||||
});
|
||||
@@ -727,7 +728,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return getCodeActions(model, model.getFullModelRange()).then(value => {
|
||||
return getCodeActions(model, model.getFullModelRange(), undefined).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
});
|
||||
});
|
||||
@@ -841,8 +842,10 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return rename(model, new EditorPosition(1, 1), 'newName').then(value => {
|
||||
assert.equal(value.edits.length, 1); // least relevant renamer
|
||||
assert.equal((<ResourceTextEdit[]>value.edits)[0].edits.length, 2); // least relevant renamer
|
||||
// least relevant rename provider
|
||||
assert.equal(value.edits.length, 2);
|
||||
assert.equal((<ResourceTextEdit>value.edits[0]).edits.length, 1);
|
||||
assert.equal((<ResourceTextEdit>value.edits[1]).edits.length, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -869,7 +872,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return provideSignatureHelp(model, new EditorPosition(1, 1)).then(value => {
|
||||
return provideSignatureHelp(model, new EditorPosition(1, 1), CancellationToken.None).then(value => {
|
||||
assert.ok(value);
|
||||
});
|
||||
});
|
||||
@@ -884,7 +887,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
|
||||
return provideSignatureHelp(model, new EditorPosition(1, 1)).then(value => {
|
||||
return provideSignatureHelp(model, new EditorPosition(1, 1), CancellationToken.None).then(value => {
|
||||
assert.equal(value, undefined);
|
||||
});
|
||||
});
|
||||
@@ -1149,7 +1152,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return getLinks(model).then(value => {
|
||||
return getLinks(model, CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
let [first] = value;
|
||||
|
||||
@@ -1174,7 +1177,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return getLinks(model).then(value => {
|
||||
return getLinks(model, CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
let [first] = value;
|
||||
|
||||
@@ -1196,7 +1199,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return getColors(model).then(value => {
|
||||
return getColors(model, CancellationToken.None).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
let [first] = value;
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
|
||||
const emptyDialogService = new class implements IDialogService {
|
||||
_serviceBrand: 'dialogService';
|
||||
show(severity, message, buttons): never {
|
||||
show(): never {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
confirm(...opts): never {
|
||||
confirm(): never {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
};
|
||||
@@ -83,7 +83,7 @@ suite('ExtHostMessageService', function () {
|
||||
let service = new MainThreadMessageService(null, new EmptyNotificationService(notification => {
|
||||
assert.equal(notification.actions.primary.length, 1);
|
||||
setImmediate(() => notification.actions.primary[0].run());
|
||||
}), emptyCommandService, emptyDialogService, null);
|
||||
}), emptyCommandService, emptyDialogService);
|
||||
|
||||
return service.$showMessage(1, 'h', {}, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]).then(handle => {
|
||||
assert.equal(handle, 42);
|
||||
@@ -100,7 +100,7 @@ suite('ExtHostMessageService', function () {
|
||||
assert.equal(buttons[1], 'Cancel');
|
||||
return Promise.as(0);
|
||||
}
|
||||
} as IDialogService, null);
|
||||
} as IDialogService);
|
||||
|
||||
return service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: false }]).then(handle => {
|
||||
assert.equal(handle, 42);
|
||||
@@ -112,7 +112,7 @@ suite('ExtHostMessageService', function () {
|
||||
show(severity, message, buttons) {
|
||||
return Promise.as(1);
|
||||
}
|
||||
} as IDialogService, null);
|
||||
} as IDialogService);
|
||||
|
||||
return service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: false }]).then(handle => {
|
||||
assert.equal(handle, undefined);
|
||||
@@ -125,7 +125,7 @@ suite('ExtHostMessageService', function () {
|
||||
assert.equal(buttons.length, 1);
|
||||
return Promise.as(0);
|
||||
}
|
||||
} as IDialogService, null);
|
||||
} as IDialogService);
|
||||
|
||||
return service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]).then(handle => {
|
||||
assert.equal(handle, 42);
|
||||
|
||||
1137
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
Normal file
1137
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,21 +6,22 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { TextEditorLineNumbersStyle } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { TextEditorLineNumbersStyle, Range } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions';
|
||||
import { MainThreadTextEditorsShape, IResolvedTextEditorConfiguration, ITextEditorConfigurationUpdate } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { ExtHostTextEditorOptions, ExtHostTextEditor } from 'vs/workbench/api/node/extHostTextEditor';
|
||||
import { ExtHostDocumentData } from 'vs/workbench/api/node/extHostDocumentData';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
|
||||
suite('ExtHostTextEditor', () => {
|
||||
|
||||
let editor: ExtHostTextEditor;
|
||||
let doc = new ExtHostDocumentData(undefined, URI.file(''), [
|
||||
'aaaa bbbb+cccc abc'
|
||||
], '\n', 'text', 1, false);
|
||||
|
||||
setup(() => {
|
||||
let doc = new ExtHostDocumentData(undefined, URI.file(''), [
|
||||
'aaaa bbbb+cccc abc'
|
||||
], '\n', 'text', 1, false);
|
||||
editor = new ExtHostTextEditor(null, 'fake', doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4 }, [], 1);
|
||||
});
|
||||
|
||||
@@ -39,6 +40,25 @@ suite('ExtHostTextEditor', () => {
|
||||
assert.throws(() => editor._acceptOptions(null));
|
||||
assert.throws(() => editor._acceptSelections([]));
|
||||
});
|
||||
|
||||
test('API [bug]: registerTextEditorCommand clears redo stack even if no edits are made #55163', async function () {
|
||||
let applyCount = 0;
|
||||
let editor = new ExtHostTextEditor(new class extends mock<MainThreadTextEditorsShape>() {
|
||||
$tryApplyEdits(): TPromise<boolean> {
|
||||
applyCount += 1;
|
||||
return TPromise.wrap(true);
|
||||
}
|
||||
}, 'edt1', doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4 }, [], 1);
|
||||
|
||||
await editor.edit(edit => { });
|
||||
assert.equal(applyCount, 0);
|
||||
|
||||
await editor.edit(edit => { edit.setEndOfLine(1); });
|
||||
assert.equal(applyCount, 1);
|
||||
|
||||
await editor.edit(edit => { edit.delete(new Range(0, 0, 1, 1)); });
|
||||
assert.equal(applyCount, 2);
|
||||
});
|
||||
});
|
||||
|
||||
suite('ExtHostTextEditorOptions', () => {
|
||||
|
||||
@@ -31,8 +31,8 @@ suite('ExtHostTreeView', function () {
|
||||
$registerTreeViewDataProvider(treeViewId: string): void {
|
||||
}
|
||||
|
||||
$refresh(viewId: string, itemsToRefresh?: { [treeItemHandle: string]: ITreeItem }): void {
|
||||
this.onRefresh.fire(itemsToRefresh);
|
||||
$refresh(viewId: string, itemsToRefresh?: { [treeItemHandle: string]: ITreeItem }): TPromise<void> {
|
||||
return TPromise.as(null).then(() => this.onRefresh.fire(itemsToRefresh));
|
||||
}
|
||||
|
||||
$reveal(): TPromise<void> {
|
||||
@@ -72,17 +72,13 @@ suite('ExtHostTreeView', function () {
|
||||
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, rpcProtocol));
|
||||
target = new RecordingShape();
|
||||
testObject = new ExtHostTreeViews(target, new ExtHostCommands(rpcProtocol, new ExtHostHeapService(), new NullLogService()));
|
||||
testObject = new ExtHostTreeViews(target, new ExtHostCommands(rpcProtocol, new ExtHostHeapService(), new NullLogService()), new NullLogService());
|
||||
onDidChangeTreeNode = new Emitter<{ key: string }>();
|
||||
onDidChangeTreeNodeWithId = new Emitter<{ key: string }>();
|
||||
testObject.createTreeView('testNodeTreeProvider', { treeDataProvider: aNodeTreeDataProvider() });
|
||||
testObject.createTreeView('testNodeWithIdTreeProvider', { treeDataProvider: aNodeWithIdTreeDataProvider() });
|
||||
|
||||
testObject.$getChildren('testNodeTreeProvider').then(elements => {
|
||||
for (const element of elements) {
|
||||
testObject.$getChildren('testNodeTreeProvider', element.handle);
|
||||
}
|
||||
});
|
||||
return loadCompleteTree('testNodeTreeProvider');
|
||||
});
|
||||
|
||||
test('construct node tree', () => {
|
||||
@@ -319,7 +315,6 @@ suite('ExtHostTreeView', function () {
|
||||
'a/0:b': {}
|
||||
};
|
||||
|
||||
onDidChangeTreeNode.fire();
|
||||
target.onRefresh.event(() => {
|
||||
testObject.$getChildren('testNodeTreeProvider')
|
||||
.then(elements => {
|
||||
@@ -327,6 +322,7 @@ suite('ExtHostTreeView', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
onDidChangeTreeNode.fire();
|
||||
});
|
||||
|
||||
test('tree with duplicate labels', (done) => {
|
||||
@@ -361,8 +357,6 @@ suite('ExtHostTreeView', function () {
|
||||
tree['f'] = {};
|
||||
tree[dupItems['adup2']] = {};
|
||||
|
||||
onDidChangeTreeNode.fire();
|
||||
|
||||
target.onRefresh.event(() => {
|
||||
testObject.$getChildren('testNodeTreeProvider')
|
||||
.then(elements => {
|
||||
@@ -376,6 +370,8 @@ suite('ExtHostTreeView', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
onDidChangeTreeNode.fire();
|
||||
});
|
||||
|
||||
test('getChildren is not returned from cache if refreshed', (done) => {
|
||||
@@ -383,7 +379,6 @@ suite('ExtHostTreeView', function () {
|
||||
'c': {}
|
||||
};
|
||||
|
||||
onDidChangeTreeNode.fire();
|
||||
target.onRefresh.event(() => {
|
||||
testObject.$getChildren('testNodeTreeProvider')
|
||||
.then(elements => {
|
||||
@@ -391,6 +386,8 @@ suite('ExtHostTreeView', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
onDidChangeTreeNode.fire();
|
||||
});
|
||||
|
||||
test('getChildren is returned from cache if not refreshed', () => {
|
||||
@@ -419,7 +416,7 @@ suite('ExtHostTreeView', function () {
|
||||
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
|
||||
assert.deepEqual({ handle: '0/0:a', label: 'a', collapsibleState: TreeItemCollapsibleState.Collapsed }, removeUnsetKeys(revealTarget.args[0][1]));
|
||||
assert.deepEqual([], revealTarget.args[0][2]);
|
||||
assert.equal(void 0, revealTarget.args[0][3]);
|
||||
assert.deepEqual({ select: true, focus: false }, revealTarget.args[0][3]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -432,7 +429,7 @@ suite('ExtHostTreeView', function () {
|
||||
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
|
||||
assert.deepEqual({ handle: '0/0:a/0:aa', label: 'aa', collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' }, removeUnsetKeys(revealTarget.args[0][1]));
|
||||
assert.deepEqual([{ handle: '0/0:a', label: 'a', collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
|
||||
assert.equal(void 0, revealTarget.args[0][3]);
|
||||
assert.deepEqual({ select: true, focus: false }, revealTarget.args[0][3]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -447,7 +444,7 @@ suite('ExtHostTreeView', function () {
|
||||
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
|
||||
assert.deepEqual({ handle: '0/0:a/0:aa', label: 'aa', collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' }, removeUnsetKeys(revealTarget.args[0][1]));
|
||||
assert.deepEqual([{ handle: '0/0:a', label: 'a', collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
|
||||
assert.equal(void 0, revealTarget.args[0][3]);
|
||||
assert.deepEqual({ select: true, focus: false }, revealTarget.args[0][3]);
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -461,7 +458,7 @@ suite('ExtHostTreeView', function () {
|
||||
};
|
||||
const revealTarget = sinon.spy(target, '$reveal');
|
||||
const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() });
|
||||
return treeView.reveal({ key: 'bac' }, { select: false })
|
||||
return treeView.reveal({ key: 'bac' }, { select: false, focus: false })
|
||||
.then(() => {
|
||||
assert.ok(revealTarget.calledOnce);
|
||||
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
|
||||
@@ -470,10 +467,16 @@ suite('ExtHostTreeView', function () {
|
||||
{ handle: '0/0:b', label: 'b', collapsibleState: TreeItemCollapsibleState.Collapsed },
|
||||
{ handle: '0/0:b/0:ba', label: 'ba', collapsibleState: TreeItemCollapsibleState.Collapsed, parentHandle: '0/0:b' }
|
||||
], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
|
||||
assert.deepEqual({ select: false }, revealTarget.args[0][3]);
|
||||
assert.deepEqual({ select: false, focus: false }, revealTarget.args[0][3]);
|
||||
});
|
||||
});
|
||||
|
||||
function loadCompleteTree(treeId, element?: string): TPromise<void> {
|
||||
return testObject.$getChildren(treeId, element)
|
||||
.then(elements => elements.map(e => loadCompleteTree(treeId, e.handle)))
|
||||
.then(() => null);
|
||||
}
|
||||
|
||||
function removeUnsetKeys(obj: any): any {
|
||||
const result = {};
|
||||
for (const key of Object.keys(obj)) {
|
||||
|
||||
@@ -21,8 +21,22 @@ suite('ExtHostTypes', function () {
|
||||
test('URI, toJSON', function () {
|
||||
|
||||
let uri = URI.parse('file:///path/test.file');
|
||||
let data = uri.toJSON();
|
||||
assert.deepEqual(data, {
|
||||
assert.deepEqual(uri.toJSON(), {
|
||||
$mid: 1,
|
||||
scheme: 'file',
|
||||
path: '/path/test.file'
|
||||
});
|
||||
|
||||
assert.ok(uri.fsPath);
|
||||
assert.deepEqual(uri.toJSON(), {
|
||||
$mid: 1,
|
||||
scheme: 'file',
|
||||
path: '/path/test.file',
|
||||
fsPath: '/path/test.file'.replace(/\//g, isWindows ? '\\' : '/'),
|
||||
});
|
||||
|
||||
assert.ok(uri.toString());
|
||||
assert.deepEqual(uri.toJSON(), {
|
||||
$mid: 1,
|
||||
scheme: 'file',
|
||||
path: '/path/test.file',
|
||||
@@ -182,8 +196,8 @@ suite('ExtHostTypes', function () {
|
||||
assert.throws(() => new types.Range(null, new types.Position(0, 0)));
|
||||
|
||||
let range = new types.Range(1, 0, 0, 0);
|
||||
assert.throws(() => (range as any).start = null);
|
||||
assert.throws(() => (range as any).start = new types.Position(0, 3));
|
||||
assert.throws(() => { (range as any).start = null; });
|
||||
assert.throws(() => { (range as any).start = new types.Position(0, 3); });
|
||||
});
|
||||
|
||||
test('Range, toJSON', function () {
|
||||
@@ -342,72 +356,73 @@ suite('ExtHostTypes', function () {
|
||||
edit.set(a, [types.TextEdit.insert(new types.Position(0, 0), 'fff')]);
|
||||
assert.ok(edit.has(a));
|
||||
assert.equal(edit.size, 1);
|
||||
assertToJSON(edit, [[URI.parse('file:///a.ts').toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]]]);
|
||||
assertToJSON(edit, [[a.toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]]]);
|
||||
|
||||
edit.insert(b, new types.Position(1, 1), 'fff');
|
||||
edit.delete(b, new types.Range(0, 0, 0, 0));
|
||||
assert.ok(edit.has(b));
|
||||
assert.equal(edit.size, 2);
|
||||
assertToJSON(edit, [
|
||||
[URI.parse('file:///a.ts').toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]],
|
||||
[URI.parse('file:///b.ts').toJSON(), [{ range: [{ line: 1, character: 1 }, { line: 1, character: 1 }], newText: 'fff' }, { range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: '' }]]
|
||||
[a.toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]],
|
||||
[b.toJSON(), [{ range: [{ line: 1, character: 1 }, { line: 1, character: 1 }], newText: 'fff' }, { range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: '' }]]
|
||||
]);
|
||||
|
||||
edit.set(b, undefined);
|
||||
assert.ok(edit.has(b));
|
||||
assert.equal(edit.size, 2);
|
||||
assert.ok(!edit.has(b));
|
||||
assert.equal(edit.size, 1);
|
||||
|
||||
edit.set(b, [types.TextEdit.insert(new types.Position(0, 0), 'ffff')]);
|
||||
assert.equal(edit.get(b).length, 1);
|
||||
|
||||
});
|
||||
|
||||
// test('WorkspaceEdit should fail when editing deleted resource', () => {
|
||||
// const resource = URI.parse('file:///a.ts');
|
||||
test('WorkspaceEdit - keep order of text and file changes', function () {
|
||||
|
||||
// const edit = new types.WorkspaceEdit();
|
||||
// edit.deleteResource(resource);
|
||||
// try {
|
||||
// edit.insert(resource, new types.Position(0, 0), '');
|
||||
// assert.fail(false, 'Should disallow edit of deleted resource');
|
||||
// } catch {
|
||||
// // expected
|
||||
// }
|
||||
// });
|
||||
const edit = new types.WorkspaceEdit();
|
||||
edit.replace(URI.parse('foo:a'), new types.Range(1, 1, 1, 1), 'foo');
|
||||
edit.renameFile(URI.parse('foo:a'), URI.parse('foo:b'));
|
||||
edit.replace(URI.parse('foo:a'), new types.Range(2, 1, 2, 1), 'bar');
|
||||
edit.replace(URI.parse('foo:b'), new types.Range(3, 1, 3, 1), 'bazz');
|
||||
|
||||
// test('WorkspaceEdit - keep order of text and file changes', function () {
|
||||
const all = edit._allEntries();
|
||||
assert.equal(all.length, 4);
|
||||
|
||||
// const edit = new types.WorkspaceEdit();
|
||||
// edit.replace(URI.parse('foo:a'), new types.Range(1, 1, 1, 1), 'foo');
|
||||
// edit.renameResource(URI.parse('foo:a'), URI.parse('foo:b'));
|
||||
// edit.replace(URI.parse('foo:a'), new types.Range(2, 1, 2, 1), 'bar');
|
||||
// edit.replace(URI.parse('foo:b'), new types.Range(3, 1, 3, 1), 'bazz');
|
||||
function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, URI, { overwrite?: boolean }] {
|
||||
const [f, s] = thing;
|
||||
return URI.isUri(f) && URI.isUri(s);
|
||||
}
|
||||
|
||||
// const all = edit.allEntries();
|
||||
// assert.equal(all.length, 3);
|
||||
function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, types.TextEdit[]] {
|
||||
const [f, s] = thing;
|
||||
return URI.isUri(f) && Array.isArray(s);
|
||||
}
|
||||
|
||||
// function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, URI] {
|
||||
// const [f, s] = thing;
|
||||
// return URI.isUri(f) && URI.isUri(s);
|
||||
// }
|
||||
const [first, second, third, fourth] = all;
|
||||
assert.equal(first[0].toString(), 'foo:a');
|
||||
assert.ok(!isFileChange(first));
|
||||
assert.ok(isTextChange(first) && first[1].length === 1);
|
||||
|
||||
// function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, types.TextEdit[]] {
|
||||
// const [f, s] = thing;
|
||||
// return URI.isUri(f) && Array.isArray(s);
|
||||
// }
|
||||
assert.equal(second[0].toString(), 'foo:a');
|
||||
assert.ok(isFileChange(second));
|
||||
|
||||
// const [first, second, third] = all;
|
||||
// assert.equal(first[0].toString(), 'foo:a');
|
||||
// assert.ok(!isFileChange(first));
|
||||
// assert.ok(isTextChange(first) && first[1].length === 2);
|
||||
assert.equal(third[0].toString(), 'foo:a');
|
||||
assert.ok(isTextChange(third) && third[1].length === 1);
|
||||
|
||||
// assert.equal(second[0].toString(), 'foo:a');
|
||||
// assert.ok(isFileChange(second));
|
||||
assert.equal(fourth[0].toString(), 'foo:b');
|
||||
assert.ok(!isFileChange(fourth));
|
||||
assert.ok(isTextChange(fourth) && fourth[1].length === 1);
|
||||
});
|
||||
|
||||
// assert.equal(third[0].toString(), 'foo:b');
|
||||
// assert.ok(!isFileChange(third));
|
||||
// assert.ok(isTextChange(third) && third[1].length === 1);
|
||||
// });
|
||||
test('WorkspaceEdit - two edits for one resource', function () {
|
||||
let edit = new types.WorkspaceEdit();
|
||||
let uri = URI.parse('foo:bar');
|
||||
edit.insert(uri, new types.Position(0, 0), 'Hello');
|
||||
edit.insert(uri, new types.Position(0, 0), 'Foo');
|
||||
|
||||
assert.equal(edit._allEntries().length, 2);
|
||||
let [first, second] = edit._allEntries();
|
||||
assert.equal((first as [URI, types.TextEdit[]])[1][0].newText, 'Hello');
|
||||
assert.equal((second as [URI, types.TextEdit[]])[1][0].newText, 'Foo');
|
||||
});
|
||||
|
||||
test('DocumentLink', function () {
|
||||
assert.throws(() => new types.DocumentLink(null, null));
|
||||
|
||||
@@ -11,11 +11,11 @@ import { ExtHostWebviews } from 'vs/workbench/api/node/extHostWebview';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import * as vscode from 'vscode';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { Position as EditorPosition } from 'vs/platform/editor/common/editor';
|
||||
import { EditorViewColumn } from 'vs/workbench/api/shared/editor';
|
||||
|
||||
suite('ExtHostWebview', function () {
|
||||
|
||||
test('Cannot register multiple serializer for the same view type', async () => {
|
||||
test('Cannot register multiple serializers for the same view type', async () => {
|
||||
const viewType = 'view.type';
|
||||
|
||||
const shape = createNoopMainThreadWebviews();
|
||||
@@ -24,9 +24,7 @@ suite('ExtHostWebview', function () {
|
||||
let lastInvokedDeserializer: vscode.WebviewPanelSerializer | undefined = undefined;
|
||||
|
||||
class NoopSerializer implements vscode.WebviewPanelSerializer {
|
||||
async serializeWebviewPanel(webview: vscode.WebviewPanel): Promise<any> { /* noop */ }
|
||||
|
||||
async deserializeWebviewPanel(webview: vscode.WebviewPanel, state: any): Promise<void> {
|
||||
async deserializeWebviewPanel(_webview: vscode.WebviewPanel, _state: any): Promise<void> {
|
||||
lastInvokedDeserializer = this;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +34,7 @@ suite('ExtHostWebview', function () {
|
||||
|
||||
const serializerARegistration = extHostWebviews.registerWebviewPanelSerializer(viewType, serializerA);
|
||||
|
||||
await extHostWebviews.$deserializeWebviewPanel('x', viewType, 'title', {}, EditorPosition.ONE, {});
|
||||
await extHostWebviews.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {});
|
||||
assert.strictEqual(lastInvokedDeserializer, serializerA);
|
||||
|
||||
assert.throws(
|
||||
@@ -47,7 +45,7 @@ suite('ExtHostWebview', function () {
|
||||
|
||||
extHostWebviews.registerWebviewPanelSerializer(viewType, serializerB);
|
||||
|
||||
await extHostWebviews.$deserializeWebviewPanel('x', viewType, 'title', {}, EditorPosition.ONE, {});
|
||||
await extHostWebviews.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {});
|
||||
assert.strictEqual(lastInvokedDeserializer, serializerB);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import { normalize } from 'vs/base/common/paths';
|
||||
import { IWorkspaceFolderData } from 'vs/platform/workspace/common/workspace';
|
||||
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
|
||||
suite('ExtHostWorkspace', function () {
|
||||
|
||||
@@ -23,8 +24,9 @@ suite('ExtHostWorkspace', function () {
|
||||
publisher: 'vscode',
|
||||
enableProposedApi: false,
|
||||
engines: undefined,
|
||||
extensionFolderPath: undefined,
|
||||
extensionLocation: undefined,
|
||||
isBuiltin: false,
|
||||
isUnderDevelopment: false,
|
||||
version: undefined
|
||||
};
|
||||
|
||||
@@ -176,7 +178,7 @@ suite('ExtHostWorkspace', function () {
|
||||
let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
|
||||
|
||||
let finished = false;
|
||||
const finish = (error?) => {
|
||||
const finish = (error?: any) => {
|
||||
if (!finished) {
|
||||
finished = true;
|
||||
done(error);
|
||||
@@ -510,6 +512,8 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
finish();
|
||||
});
|
||||
|
||||
// {{SQL CARBON EDIT}} remove broken test
|
||||
|
||||
test('`vscode.workspace.getWorkspaceFolder(file)` don\'t return workspace folder when file open from command line. #36221', function () {
|
||||
let ws = new ExtHostWorkspace(new TestRPCProtocol(), {
|
||||
|
||||
@@ -10,24 +10,35 @@ import { MainThreadDocumentsAndEditors } from 'vs/workbench/api/electron-browser
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { TestCodeEditorService } from 'vs/editor/test/browser/testCodeEditorService';
|
||||
import { TestCodeEditorService } from 'vs/editor/test/browser/editorTestServices';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ExtHostDocumentsAndEditorsShape, IDocumentsAndEditorsDelta } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { createTestCodeEditor, TestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { TestEditorService, TestEditorGroupsService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
|
||||
suite('MainThreadDocumentsAndEditors', () => {
|
||||
|
||||
let modelService: ModelServiceImpl;
|
||||
let codeEditorService: TestCodeEditorService;
|
||||
let textFileService: ITextFileService;
|
||||
let workbenchEditorService: IWorkbenchEditorService;
|
||||
let deltas: IDocumentsAndEditorsDelta[] = [];
|
||||
const hugeModelString = new Array(2 + (50 * 1024 * 1024)).join('-');
|
||||
|
||||
function myCreateTestCodeEditor(model: ITextModel): TestCodeEditor {
|
||||
return createTestCodeEditor({
|
||||
model: model,
|
||||
serviceCollection: new ServiceCollection(
|
||||
[ICodeEditorService, codeEditorService]
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
setup(() => {
|
||||
deltas.length = 0;
|
||||
const configService = new TestConfigurationService();
|
||||
@@ -42,29 +53,28 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
onModelDirty: Event.None,
|
||||
};
|
||||
};
|
||||
workbenchEditorService = <IWorkbenchEditorService>{
|
||||
getVisibleEditors() { return []; },
|
||||
getActiveEditor() { return undefined; }
|
||||
};
|
||||
const editorGroupService = new class extends mock<IEditorGroupService>() {
|
||||
onEditorsChanged = Event.None;
|
||||
onEditorGroupMoved = Event.None;
|
||||
const workbenchEditorService = new TestEditorService();
|
||||
const editorGroupService = new TestEditorGroupsService();
|
||||
|
||||
const fileService = new class extends mock<IFileService>() {
|
||||
onAfterOperation = Event.None;
|
||||
};
|
||||
|
||||
/* tslint:disable */
|
||||
new MainThreadDocumentsAndEditors(
|
||||
SingleProxyRPCProtocol(new class extends mock<ExtHostDocumentsAndEditorsShape>() {
|
||||
$acceptDocumentsAndEditorsDelta(delta) { deltas.push(delta); }
|
||||
$acceptDocumentsAndEditorsDelta(delta: IDocumentsAndEditorsDelta) { deltas.push(delta); }
|
||||
}),
|
||||
modelService,
|
||||
textFileService,
|
||||
workbenchEditorService,
|
||||
codeEditorService,
|
||||
null,
|
||||
null,
|
||||
fileService,
|
||||
null,
|
||||
null,
|
||||
editorGroupService,
|
||||
null
|
||||
);
|
||||
/* tslint:enable */
|
||||
});
|
||||
@@ -119,18 +129,17 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
this.timeout(1000 * 60); // increase timeout for this one test
|
||||
|
||||
const model = modelService.createModel(hugeModelString, null, null);
|
||||
const editor = createTestCodeEditor(model);
|
||||
const editor = myCreateTestCodeEditor(model);
|
||||
|
||||
assert.equal(deltas.length, 1);
|
||||
deltas.length = 0;
|
||||
codeEditorService.addCodeEditor(editor);
|
||||
assert.equal(deltas.length, 0);
|
||||
|
||||
editor.dispose();
|
||||
});
|
||||
|
||||
test('ignore editor w/o model', () => {
|
||||
const editor = createTestCodeEditor(null);
|
||||
editor.setModel(null);
|
||||
codeEditorService.addCodeEditor(editor);
|
||||
const editor = myCreateTestCodeEditor(null);
|
||||
assert.equal(deltas.length, 1);
|
||||
const [delta] = deltas;
|
||||
assert.equal(delta.newActiveEditor, null);
|
||||
@@ -138,13 +147,15 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
assert.equal(delta.removedDocuments, undefined);
|
||||
assert.equal(delta.addedEditors, undefined);
|
||||
assert.equal(delta.removedEditors, undefined);
|
||||
|
||||
editor.dispose();
|
||||
});
|
||||
|
||||
test('editor with model', () => {
|
||||
deltas.length = 0;
|
||||
|
||||
const model = modelService.createModel('farboo', null, null);
|
||||
codeEditorService.addCodeEditor(createTestCodeEditor(model));
|
||||
const editor = myCreateTestCodeEditor(model);
|
||||
|
||||
assert.equal(deltas.length, 2);
|
||||
const [first, second] = deltas;
|
||||
@@ -158,14 +169,15 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
assert.equal(second.addedDocuments, undefined);
|
||||
assert.equal(second.removedDocuments, undefined);
|
||||
assert.equal(second.removedEditors, undefined);
|
||||
assert.equal(typeof second.newActiveEditor, 'string');
|
||||
assert.equal(second.newActiveEditor, undefined);
|
||||
|
||||
editor.dispose();
|
||||
});
|
||||
|
||||
test('editor with dispos-ed/-ing model', () => {
|
||||
modelService.createModel('foobar', null, null);
|
||||
const model = modelService.createModel('farboo', null, null);
|
||||
const editor = createTestCodeEditor(model);
|
||||
codeEditorService.addCodeEditor(editor);
|
||||
const editor = myCreateTestCodeEditor(model);
|
||||
|
||||
// ignore things until now
|
||||
deltas.length = 0;
|
||||
@@ -179,5 +191,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
assert.equal(first.removedDocuments.length, 1);
|
||||
assert.equal(first.addedDocuments, undefined);
|
||||
assert.equal(first.addedEditors, undefined);
|
||||
|
||||
editor.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,12 +10,10 @@ import { MainThreadDocumentsAndEditors } from 'vs/workbench/api/electron-browser
|
||||
import { SingleProxyRPCProtocol, TestRPCProtocol } from './testRPCProtocol';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { TestCodeEditorService } from 'vs/editor/test/browser/testCodeEditorService';
|
||||
import { TestCodeEditorService } from 'vs/editor/test/browser/editorTestServices';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ExtHostDocumentsAndEditorsShape, ExtHostContext, ExtHostDocumentsShape } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { MainThreadTextEditors } from 'vs/workbench/api/electron-browser/mainThreadEditors';
|
||||
import URI from 'vs/base/common/uri';
|
||||
@@ -23,10 +21,14 @@ import { Range } from 'vs/editor/common/core/range';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { TestFileService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestContextService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IFileStat } from 'vs/platform/files/common/files';
|
||||
import { ResourceTextEdit } from 'vs/editor/common/modes';
|
||||
import { BulkEditService } from 'vs/workbench/services/bulkEdit/electron-browser/bulkEditService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ITextModelService, ITextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
import { IReference, ImmortalReference } from 'vs/base/common/lifecycle';
|
||||
import { UriDisplayService } from 'vs/platform/uriDisplay/common/uriDisplay';
|
||||
|
||||
suite('MainThreadEditors', () => {
|
||||
|
||||
@@ -48,38 +50,41 @@ suite('MainThreadEditors', () => {
|
||||
createdResources.clear();
|
||||
deletedResources.clear();
|
||||
|
||||
const fileService = new class extends TestFileService {
|
||||
async moveFile(from, target): TPromise<IFileStat> {
|
||||
movedResources.set(from, target);
|
||||
return createMockFileStat(target);
|
||||
}
|
||||
async createFile(uri): TPromise<IFileStat> {
|
||||
createdResources.add(uri);
|
||||
return createMockFileStat(uri);
|
||||
}
|
||||
async del(uri): TPromise<any> {
|
||||
deletedResources.add(uri);
|
||||
}
|
||||
};
|
||||
|
||||
const fileService = new TestFileService();
|
||||
|
||||
const textFileService = new class extends mock<ITextFileService>() {
|
||||
isDirty() { return false; }
|
||||
create(uri: URI, contents?: string, options?: any) {
|
||||
createdResources.add(uri);
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
delete(resource: URI) {
|
||||
deletedResources.add(resource);
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
move(source: URI, target: URI) {
|
||||
movedResources.set(source, target);
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
models = <any>{
|
||||
onModelSaved: Event.None,
|
||||
onModelReverted: Event.None,
|
||||
onModelDirty: Event.None,
|
||||
};
|
||||
};
|
||||
const workbenchEditorService = <IWorkbenchEditorService>{
|
||||
getVisibleEditors() { return []; },
|
||||
getActiveEditor() { return undefined; }
|
||||
};
|
||||
const editorGroupService = new class extends mock<IEditorGroupService>() {
|
||||
onEditorsChanged = Event.None;
|
||||
onEditorGroupMoved = Event.None;
|
||||
const workbenchEditorService = new TestEditorService();
|
||||
const editorGroupService = new TestEditorGroupsService();
|
||||
const textModelService = new class extends mock<ITextModelService>() {
|
||||
createModelReference(resource: URI): TPromise<IReference<ITextEditorModel>> {
|
||||
const textEditorModel: ITextEditorModel = new class extends mock<ITextEditorModel>() {
|
||||
textEditorModel = modelService.getModel(resource);
|
||||
};
|
||||
return TPromise.as(new ImmortalReference(textEditorModel));
|
||||
}
|
||||
};
|
||||
|
||||
const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new UriDisplayService(TestEnvironmentService, new TestContextService()));
|
||||
|
||||
const rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock<ExtHostDocumentsShape>() {
|
||||
$acceptModelChanged(): void {
|
||||
@@ -101,17 +106,16 @@ suite('MainThreadEditors', () => {
|
||||
null,
|
||||
null,
|
||||
editorGroupService,
|
||||
bulkEditService,
|
||||
);
|
||||
|
||||
editors = new MainThreadTextEditors(
|
||||
documentAndEditor,
|
||||
SingleProxyRPCProtocol(null),
|
||||
codeEditorService,
|
||||
bulkEditService,
|
||||
workbenchEditorService,
|
||||
editorGroupService,
|
||||
null,
|
||||
fileService,
|
||||
modelService
|
||||
);
|
||||
});
|
||||
|
||||
@@ -136,12 +140,44 @@ suite('MainThreadEditors', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test(`issue #54773: applyWorkspaceEdit checks model version in race situation`, () => {
|
||||
|
||||
let model = modelService.createModel('something', null, resource);
|
||||
|
||||
let workspaceResourceEdit1: ResourceTextEdit = {
|
||||
resource: resource,
|
||||
modelVersionId: model.getVersionId(),
|
||||
edits: [{
|
||||
text: 'asdfg',
|
||||
range: new Range(1, 1, 1, 1)
|
||||
}]
|
||||
};
|
||||
let workspaceResourceEdit2: ResourceTextEdit = {
|
||||
resource: resource,
|
||||
modelVersionId: model.getVersionId(),
|
||||
edits: [{
|
||||
text: 'asdfg',
|
||||
range: new Range(1, 1, 1, 1)
|
||||
}]
|
||||
};
|
||||
|
||||
let p1 = editors.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit1] }).then((result) => {
|
||||
// first edit request succeeds
|
||||
assert.equal(result, true);
|
||||
});
|
||||
let p2 = editors.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit2] }).then((result) => {
|
||||
// second edit request fails
|
||||
assert.equal(result, false);
|
||||
});
|
||||
return TPromise.join([p1, p2]);
|
||||
});
|
||||
|
||||
test(`applyWorkspaceEdit with only resource edit`, () => {
|
||||
return editors.$tryApplyWorkspaceEdit({
|
||||
edits: [
|
||||
{ oldUri: resource, newUri: resource },
|
||||
{ oldUri: undefined, newUri: resource },
|
||||
{ oldUri: resource, newUri: undefined }
|
||||
{ oldUri: resource, newUri: resource, options: undefined },
|
||||
{ oldUri: undefined, newUri: resource, options: undefined },
|
||||
{ oldUri: resource, newUri: undefined, options: undefined }
|
||||
]
|
||||
}).then((result) => {
|
||||
assert.equal(result, true);
|
||||
@@ -151,15 +187,3 @@ suite('MainThreadEditors', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function createMockFileStat(target: URI): IFileStat {
|
||||
return {
|
||||
etag: '',
|
||||
isDirectory: false,
|
||||
name: target.path,
|
||||
mtime: 0,
|
||||
resource: target
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ suite('MainThreadSaveParticipant', function () {
|
||||
let lineContent = `${textContent}`;
|
||||
model.textEditorModel.setValue(lineContent);
|
||||
// apply edits and push to undo stack.
|
||||
let textEdits = [{ identifier: null, range: new Range(1, 14, 1, 14), text: '.', forceMoveMarkers: false }];
|
||||
let textEdits = [{ range: new Range(1, 14, 1, 14), text: '.', forceMoveMarkers: false }];
|
||||
model.textEditorModel.pushEditOperations([new Selection(1, 14, 1, 14)], textEdits, () => { return [new Selection(1, 15, 1, 15)]; });
|
||||
// undo
|
||||
model.textEditorModel.undo();
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ProxyIdentifier, IRPCProtocol } from 'vs/workbench/services/extensions/node/proxyIdentifier';
|
||||
import { ProxyIdentifier } from 'vs/workbench/services/extensions/node/proxyIdentifier';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
|
||||
export function SingleProxyRPCProtocol(thing: any): IRPCProtocol {
|
||||
export function SingleProxyRPCProtocol(thing: any): IExtHostContext {
|
||||
return {
|
||||
getProxy<T>(): T {
|
||||
return thing;
|
||||
@@ -21,9 +22,9 @@ export function SingleProxyRPCProtocol(thing: any): IRPCProtocol {
|
||||
};
|
||||
}
|
||||
|
||||
declare var Proxy; // TODO@TypeScript
|
||||
declare var Proxy: any; // TODO@TypeScript
|
||||
|
||||
export class TestRPCProtocol implements IRPCProtocol {
|
||||
export class TestRPCProtocol implements IExtHostContext {
|
||||
|
||||
private _callCountValue: number = 0;
|
||||
private _idle: Promise<any>;
|
||||
@@ -76,7 +77,7 @@ export class TestRPCProtocol implements IRPCProtocol {
|
||||
|
||||
private _createProxy<T>(proxyId: string): T {
|
||||
let handler = {
|
||||
get: (target, name: string) => {
|
||||
get: (target: any, name: string) => {
|
||||
if (!target[name] && name.charCodeAt(0) === CharCode.DollarSign) {
|
||||
target[name] = (...myArgs: any[]) => {
|
||||
return this._remoteCall(proxyId, name, myArgs);
|
||||
|
||||
@@ -9,24 +9,23 @@ import 'vs/workbench/parts/search/electron-browser/search.contribution'; // load
|
||||
import * as assert from 'assert';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import { ISearchService } from 'vs/platform/search/common/search';
|
||||
import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IExperimentService, IExperiments } from 'vs/platform/telemetry/common/experiments';
|
||||
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import * as minimist from 'minimist';
|
||||
import * as path from 'path';
|
||||
import { IQuickOpenRegistry, Extensions } from 'vs/workbench/browser/quickopen';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { SearchService } from 'vs/workbench/services/search/node/searchService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { TestEnvironmentService, TestEditorService, TestEditorGroupService, TestContextService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TestEnvironmentService, TestContextService, TestEditorService, TestEditorGroupsService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { SimpleConfigurationService } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
@@ -68,16 +67,14 @@ suite.skip('QuickOpen performance (integration)', () => {
|
||||
const testWorkspacePath = testWorkspaceArg ? path.resolve(testWorkspaceArg) : __dirname;
|
||||
|
||||
const telemetryService = new TestTelemetryService();
|
||||
const experimentService = new TestExperimentService();
|
||||
const configurationService = new SimpleConfigurationService();
|
||||
const configurationService = new TestConfigurationService();
|
||||
const instantiationService = new InstantiationService(new ServiceCollection(
|
||||
[ITelemetryService, telemetryService],
|
||||
[IExperimentService, experimentService],
|
||||
[IConfigurationService, configurationService],
|
||||
[IModelService, new ModelServiceImpl(null, configurationService)],
|
||||
[IWorkspaceContextService, new TestContextService(testWorkspace(URI.file(testWorkspacePath)))],
|
||||
[IWorkbenchEditorService, new TestEditorService()],
|
||||
[IEditorGroupService, new TestEditorGroupService()],
|
||||
[IEditorService, new TestEditorService()],
|
||||
[IEditorGroupsService, new TestEditorGroupsService()],
|
||||
[IEnvironmentService, TestEnvironmentService],
|
||||
[IUntitledEditorService, createSyncDescriptor(UntitledEditorService)],
|
||||
[ISearchService, createSyncDescriptor(SearchService)]
|
||||
@@ -179,12 +176,3 @@ class TestTelemetryService implements ITelemetryService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class TestExperimentService implements IExperimentService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
getExperiments(): IExperiments {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,21 +10,21 @@ import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import { ISearchService, IQueryOptions } from 'vs/platform/search/common/search';
|
||||
import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import * as minimist from 'minimist';
|
||||
import * as path from 'path';
|
||||
import { SearchService } from 'vs/workbench/services/search/node/searchService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { TestEnvironmentService, TestEditorService, TestEditorGroupService, TestContextService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TestEnvironmentService, TestContextService, TestEditorService, TestEditorGroupsService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { SimpleConfigurationService } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
@@ -42,7 +42,7 @@ declare var __dirname: string;
|
||||
// git clone --separate-git-dir=testGit --no-checkout --single-branch https://chromium.googlesource.com/chromium/src testWorkspace
|
||||
// cd testWorkspace; git checkout 39a7f93d67f7
|
||||
// Run from repository root folder with (test.bat on Windows): ./scripts/test-int-mocha.sh --grep TextSearch.performance --timeout 500000 --testWorkspace <path>
|
||||
suite('TextSearch performance (integration)', () => {
|
||||
suite.skip('TextSearch performance (integration)', () => {
|
||||
|
||||
test('Measure', () => {
|
||||
if (process.env['VSCODE_PID']) {
|
||||
@@ -58,14 +58,14 @@ suite('TextSearch performance (integration)', () => {
|
||||
}
|
||||
|
||||
const telemetryService = new TestTelemetryService();
|
||||
const configurationService = new SimpleConfigurationService();
|
||||
const configurationService = new TestConfigurationService();
|
||||
const instantiationService = new InstantiationService(new ServiceCollection(
|
||||
[ITelemetryService, telemetryService],
|
||||
[IConfigurationService, configurationService],
|
||||
[IModelService, new ModelServiceImpl(null, configurationService)],
|
||||
[IWorkspaceContextService, new TestContextService(testWorkspace(URI.file(testWorkspacePath)))],
|
||||
[IWorkbenchEditorService, new TestEditorService()],
|
||||
[IEditorGroupService, new TestEditorGroupService()],
|
||||
[IEditorService, new TestEditorService()],
|
||||
[IEditorGroupsService, new TestEditorGroupsService()],
|
||||
[IEnvironmentService, TestEnvironmentService],
|
||||
[IUntitledEditorService, createSyncDescriptor(UntitledEditorService)],
|
||||
[ISearchService, createSyncDescriptor(SearchService)],
|
||||
|
||||
@@ -10,11 +10,13 @@ import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEdi
|
||||
import { Promise, TPromise } from 'vs/base/common/winjs.base';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
|
||||
import { IEditorGroup, ConfirmResult, IEditorOpeningEvent } from 'vs/workbench/common/editor';
|
||||
import { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent } from 'vs/workbench/common/editor';
|
||||
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, EditorGroupsServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
@@ -23,14 +25,11 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
|
||||
import { IPartService, Parts, Position as PartPosition, IDimension } from 'vs/workbench/services/part/common/partService';
|
||||
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IEditorInput, IEditorOptions, Position, IEditor, IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
import { IEditorOptions, IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { IWorkspaceContextService, IWorkspace as IWorkbenchWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent } from 'vs/platform/workspace/common/workspace';
|
||||
import { IWorkspaceContextService, IWorkspace as IWorkbenchWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, Workspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { ILifecycleService, ShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { EditorStacksModel } from 'vs/workbench/common/editor/editorStacksModel';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { IEditorGroupService, GroupArrangement, GroupOrientation, IEditorTabOptions, IMoveOptions } from 'vs/workbench/services/group/common/groupService';
|
||||
import { TextFileService } from 'vs/workbench/services/textfile/common/textFileService';
|
||||
import { FileOperationEvent, IFileService, IResolveContentOptions, FileOperationError, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, IContent, IUpdateContentOptions, IStreamContent, ICreateFileOptions, ITextSnapshot, IResourceEncodings } from 'vs/platform/files/common/files';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
@@ -40,31 +39,43 @@ import { IRawTextContent, ITextFileService } from 'vs/workbench/services/textfil
|
||||
import { parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IWorkbenchEditorService, ICloseEditorsFilter } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, MenuBarVisibility } from 'vs/platform/windows/common/windows';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IRecentlyOpened } from 'vs/platform/history/common/history';
|
||||
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/position';
|
||||
import { ICommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { IMenuService, MenuId, IMenu, ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import { ITextBufferFactory, DefaultEndOfLine, EndOfLinePreference } from 'vs/editor/common/model';
|
||||
import { MockContextKeyService, MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import { ITextBufferFactory, DefaultEndOfLine, EndOfLinePreference, IModelDecorationOptions, ITextModel } from 'vs/editor/common/model';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IConfirmation, IConfirmationResult, IDialogService, IDialogOptions } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { IExtensionService, ProfileSession, IExtensionsStatus, ExtensionPointContribution, IExtensionDescription } from '../services/extensions/common/extensions';
|
||||
import { IExtensionPoint } from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
|
||||
import { IDisposable, toDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, EditorsOrder, IFindGroupScope, EditorGroupLayout } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import { IEditorService, IOpenEditorOverrideHandler } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IDecorationRenderOptions } from 'vs/editor/common/editorCommon';
|
||||
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
|
||||
import { Dimension } from 'vs/base/browser/dom';
|
||||
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
|
||||
import { IUriDisplayService, UriDisplayService } from 'vs/platform/uriDisplay/common/uriDisplay';
|
||||
|
||||
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
|
||||
return instantiationService.createInstance(FileEditorInput, resource, void 0);
|
||||
@@ -75,7 +86,7 @@ export const TestEnvironmentService = new EnvironmentService(parseArgs(process.a
|
||||
export class TestContextService implements IWorkspaceContextService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
private workspace: IWorkbenchWorkspace;
|
||||
private workspace: Workspace;
|
||||
private options: any;
|
||||
|
||||
private readonly _onDidChangeWorkspaceName: Emitter<void>;
|
||||
@@ -122,7 +133,7 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
}
|
||||
|
||||
public getWorkspaceFolder(resource: URI): IWorkspaceFolder {
|
||||
return this.isInsideWorkspace(resource) ? this.workspace.folders[0] : null;
|
||||
return this.workspace.getFolder(resource);
|
||||
}
|
||||
|
||||
public setWorkspace(workspace: any): void {
|
||||
@@ -139,7 +150,7 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
|
||||
public isInsideWorkspace(resource: URI): boolean {
|
||||
if (resource && this.workspace) {
|
||||
return paths.isEqualOrParent(resource.fsPath, this.workspace.folders[0].uri.fsPath, !isLinux /* ignorecase */);
|
||||
return resources.isEqualOrParent(resource, this.workspace.folders[0].uri, resources.hasToIgnoreCase(resource));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -150,16 +161,7 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
}
|
||||
|
||||
public isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
|
||||
return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && this.pathEquals(this.workspace.folders[0].uri.fsPath, workspaceIdentifier);
|
||||
}
|
||||
|
||||
private pathEquals(path1: string, path2: string): boolean {
|
||||
if (!isLinux) {
|
||||
path1 = path1.toLowerCase();
|
||||
path2 = path2.toLowerCase();
|
||||
}
|
||||
|
||||
return path1 === path2;
|
||||
return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && resources.isEqual(this.workspace.folders[0].uri, workspaceIdentifier, resources.hasToIgnoreCase(workspaceIdentifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +176,6 @@ export class TestTextFileService extends TextFileService {
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@@ -241,15 +242,14 @@ export class TestTextFileService extends TextFileService {
|
||||
export function workbenchInstantiationService(): IInstantiationService {
|
||||
let instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
|
||||
instantiationService.stub(IContextKeyService, <IContextKeyService>instantiationService.createInstance(MockContextKeyService));
|
||||
instantiationService.stub(IWorkspaceContextService, new TestContextService(TestWorkspace));
|
||||
const workspaceContextService = new TestContextService(TestWorkspace);
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceContextService);
|
||||
const configService = new TestConfigurationService();
|
||||
instantiationService.stub(IConfigurationService, configService);
|
||||
instantiationService.stub(ITextResourceConfigurationService, new TestTextResourceConfigurationService(configService));
|
||||
instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
|
||||
instantiationService.stub(IStorageService, new TestStorageService());
|
||||
instantiationService.stub(IWorkbenchEditorService, new TestEditorService());
|
||||
instantiationService.stub(IPartService, new TestPartService());
|
||||
instantiationService.stub(IEditorGroupService, new TestEditorGroupService());
|
||||
instantiationService.stub(IModeService, ModeServiceImpl);
|
||||
instantiationService.stub(IHistoryService, new TestHistoryService());
|
||||
instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
|
||||
@@ -259,16 +259,75 @@ export function workbenchInstantiationService(): IInstantiationService {
|
||||
instantiationService.stub(INotificationService, new TestNotificationService());
|
||||
instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
|
||||
instantiationService.stub(IWindowService, new TestWindowService());
|
||||
instantiationService.stub(IMenuService, new TestMenuService());
|
||||
instantiationService.stub(IKeybindingService, new MockKeybindingService());
|
||||
instantiationService.stub(IDecorationsService, new TestDecorationsService());
|
||||
instantiationService.stub(IExtensionService, new TestExtensionService());
|
||||
instantiationService.stub(IWindowsService, new TestWindowsService());
|
||||
instantiationService.stub(ITextFileService, <ITextFileService>instantiationService.createInstance(TestTextFileService));
|
||||
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
|
||||
instantiationService.stub(IEnvironmentService, TestEnvironmentService);
|
||||
instantiationService.stub(IThemeService, new TestThemeService());
|
||||
instantiationService.stub(IHashService, new TestHashService());
|
||||
instantiationService.stub(ILogService, new TestLogService());
|
||||
instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)]));
|
||||
instantiationService.stub(IUriDisplayService, new UriDisplayService(TestEnvironmentService, workspaceContextService));
|
||||
const editorService = new TestEditorService();
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
instantiationService.stub(ICodeEditorService, new TestCodeEditorService());
|
||||
|
||||
return instantiationService;
|
||||
}
|
||||
|
||||
export class TestLogService implements ILogService {
|
||||
_serviceBrand: any; onDidChangeLogLevel: Event<LogLevel>;
|
||||
getLevel(): LogLevel { return LogLevel.Info; }
|
||||
setLevel(level: LogLevel): void { }
|
||||
trace(message: string, ...args: any[]): void { }
|
||||
debug(message: string, ...args: any[]): void { }
|
||||
info(message: string, ...args: any[]): void { }
|
||||
warn(message: string, ...args: any[]): void { }
|
||||
error(message: string | Error, ...args: any[]): void { }
|
||||
critical(message: string | Error, ...args: any[]): void { }
|
||||
dispose(): void { }
|
||||
}
|
||||
|
||||
export class TestDecorationsService implements IDecorationsService {
|
||||
_serviceBrand: any;
|
||||
onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.None;
|
||||
registerDecorationsProvider(provider: IDecorationsProvider): IDisposable { return Disposable.None; }
|
||||
getDecoration(uri: URI, includeChildren: boolean, overwrite?: IDecorationData): IDecoration { return void 0; }
|
||||
}
|
||||
|
||||
export class TestExtensionService implements IExtensionService {
|
||||
_serviceBrand: any;
|
||||
onDidRegisterExtensions: Event<void> = Event.None;
|
||||
onDidChangeExtensionsStatus: Event<string[]> = Event.None;
|
||||
activateByEvent(activationEvent: string): Promise<void> { return TPromise.as(void 0); }
|
||||
whenInstalledExtensionsRegistered(): Promise<boolean> { return TPromise.as(true); }
|
||||
getExtensions(): Promise<IExtensionDescription[]> { return TPromise.as([]); }
|
||||
readExtensionPointContributions<T>(extPoint: IExtensionPoint<T>): Promise<ExtensionPointContribution<T>[]> { return TPromise.as(Object.create(null)); }
|
||||
getExtensionsStatus(): { [id: string]: IExtensionsStatus; } { return Object.create(null); }
|
||||
canProfileExtensionHost(): boolean { return false; }
|
||||
startExtensionHostProfile(): Promise<ProfileSession> { return TPromise.as(Object.create(null)); }
|
||||
restartExtensionHost(): void { }
|
||||
startExtensionHost(): void { }
|
||||
stopExtensionHost(): void { }
|
||||
}
|
||||
|
||||
export class TestMenuService implements IMenuService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
createMenu(id: MenuId, scopedKeybindingService: IContextKeyService): IMenu {
|
||||
return {
|
||||
onDidChange: Event.None,
|
||||
dispose: () => void 0,
|
||||
getActions: () => []
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class TestHistoryService implements IHistoryService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
@@ -325,12 +384,17 @@ export class TestPartService implements IPartService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
private _onTitleBarVisibilityChange = new Emitter<void>();
|
||||
private _onMenubarVisibilityChange = new Emitter<Dimension>();
|
||||
private _onEditorLayout = new Emitter<IDimension>();
|
||||
|
||||
public get onTitleBarVisibilityChange(): Event<void> {
|
||||
return this._onTitleBarVisibilityChange.event;
|
||||
}
|
||||
|
||||
public get onMenubarVisibilityChange(): Event<Dimension> {
|
||||
return this._onMenubarVisibilityChange.event;
|
||||
}
|
||||
|
||||
public get onEditorLayout(): Event<IDimension> {
|
||||
return this._onEditorLayout.event;
|
||||
}
|
||||
@@ -389,6 +453,10 @@ export class TestPartService implements IPartService {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getMenubarVisibility(): MenuBarVisibility {
|
||||
return null;
|
||||
}
|
||||
|
||||
public getSideBarPosition() {
|
||||
return 0;
|
||||
}
|
||||
@@ -445,207 +513,224 @@ export class TestStorageService implements IStorageService {
|
||||
}
|
||||
}
|
||||
|
||||
export class TestEditorGroupService implements IEditorGroupService {
|
||||
public _serviceBrand: any;
|
||||
export class TestEditorGroupsService implements EditorGroupsServiceImpl {
|
||||
_serviceBrand: ServiceIdentifier<any>;
|
||||
|
||||
private stacksModel: EditorStacksModel;
|
||||
constructor(public groups: TestEditorGroup[] = []) { }
|
||||
|
||||
private readonly _onEditorsChanged: Emitter<void>;
|
||||
private readonly _onEditorOpening: Emitter<IEditorOpeningEvent>;
|
||||
private readonly _onEditorOpenFail: Emitter<IEditorInput>;
|
||||
private readonly _onEditorsMoved: Emitter<void>;
|
||||
private readonly _onGroupOrientationChanged: Emitter<void>;
|
||||
private readonly _onTabOptionsChanged: Emitter<IEditorTabOptions>;
|
||||
onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
|
||||
onDidAddGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidRemoveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidMoveGroup: Event<IEditorGroup> = Event.None;
|
||||
|
||||
constructor(callback?: (method: string) => void) {
|
||||
this._onEditorsMoved = new Emitter<void>();
|
||||
this._onEditorsChanged = new Emitter<void>();
|
||||
this._onEditorOpening = new Emitter<IEditorOpeningEvent>();
|
||||
this._onGroupOrientationChanged = new Emitter<void>();
|
||||
this._onEditorOpenFail = new Emitter<IEditorInput>();
|
||||
this._onTabOptionsChanged = new Emitter<IEditorTabOptions>();
|
||||
orientation: any;
|
||||
whenRestored: TPromise<void> = TPromise.as(void 0);
|
||||
|
||||
let services = new ServiceCollection();
|
||||
|
||||
services.set(IStorageService, new TestStorageService());
|
||||
services.set(IConfigurationService, new TestConfigurationService());
|
||||
services.set(IWorkspaceContextService, new TestContextService());
|
||||
const lifecycle = new TestLifecycleService();
|
||||
services.set(ILifecycleService, lifecycle);
|
||||
services.set(ITelemetryService, NullTelemetryService);
|
||||
|
||||
let inst = new InstantiationService(services);
|
||||
|
||||
this.stacksModel = inst.createInstance(EditorStacksModel, true);
|
||||
get activeGroup(): IEditorGroup {
|
||||
return this.groups[0];
|
||||
}
|
||||
|
||||
public fireChange(): void {
|
||||
this._onEditorsChanged.fire();
|
||||
get count(): number {
|
||||
return this.groups.length;
|
||||
}
|
||||
|
||||
public get onEditorsChanged(): Event<void> {
|
||||
return this._onEditorsChanged.event;
|
||||
getGroups(order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
|
||||
return this.groups;
|
||||
}
|
||||
|
||||
public get onEditorOpening(): Event<IEditorOpeningEvent> {
|
||||
return this._onEditorOpening.event;
|
||||
getGroup(identifier: number): IEditorGroup {
|
||||
for (let i = 0; i < this.groups.length; i++) {
|
||||
if (this.groups[i].id === identifier) {
|
||||
return this.groups[i];
|
||||
}
|
||||
}
|
||||
|
||||
return void 0;
|
||||
}
|
||||
|
||||
public get onEditorOpenFail(): Event<IEditorInput> {
|
||||
return this._onEditorOpenFail.event;
|
||||
getLabel(identifier: number): string {
|
||||
return 'Group 1';
|
||||
}
|
||||
|
||||
public get onEditorGroupMoved(): Event<void> {
|
||||
return this._onEditorsMoved.event;
|
||||
findGroup(scope: IFindGroupScope, source?: number | IEditorGroup, wrap?: boolean): IEditorGroup {
|
||||
return null;
|
||||
}
|
||||
|
||||
public get onGroupOrientationChanged(): Event<void> {
|
||||
return this._onGroupOrientationChanged.event;
|
||||
activateGroup(group: number | IEditorGroup): IEditorGroup {
|
||||
return null;
|
||||
}
|
||||
|
||||
public get onTabOptionsChanged(): Event<IEditorTabOptions> {
|
||||
return this._onTabOptionsChanged.event;
|
||||
getSize(group: number | IEditorGroup): number {
|
||||
return 100;
|
||||
}
|
||||
|
||||
public focusGroup(group: IEditorGroup): void;
|
||||
public focusGroup(position: Position): void;
|
||||
public focusGroup(arg1: any): void {
|
||||
setSize(group: number | IEditorGroup, size: number): void { }
|
||||
|
||||
arrangeGroups(arrangement: GroupsArrangement): void { }
|
||||
|
||||
applyLayout(layout: EditorGroupLayout): void { }
|
||||
|
||||
setGroupOrientation(orientation: any): void { }
|
||||
|
||||
addGroup(location: number | IEditorGroup, direction: GroupDirection, options?: IAddGroupOptions): IEditorGroup {
|
||||
return null;
|
||||
}
|
||||
|
||||
public activateGroup(group: IEditorGroup): void;
|
||||
public activateGroup(position: Position): void;
|
||||
public activateGroup(arg1: any): void {
|
||||
removeGroup(group: number | IEditorGroup): void { }
|
||||
|
||||
moveGroup(group: number | IEditorGroup, location: number | IEditorGroup, direction: GroupDirection): IEditorGroup {
|
||||
return null;
|
||||
}
|
||||
|
||||
public moveGroup(from: IEditorGroup, to: IEditorGroup): void;
|
||||
public moveGroup(from: Position, to: Position): void;
|
||||
public moveGroup(arg1: any, arg2: any): void {
|
||||
|
||||
mergeGroup(group: number | IEditorGroup, target: number | IEditorGroup, options?: IMergeGroupOptions): IEditorGroup {
|
||||
return null;
|
||||
}
|
||||
|
||||
public arrangeGroups(arrangement: GroupArrangement): void {
|
||||
|
||||
}
|
||||
|
||||
public setGroupOrientation(orientation: GroupOrientation): void {
|
||||
|
||||
}
|
||||
|
||||
public getGroupOrientation(): GroupOrientation {
|
||||
return 'vertical';
|
||||
}
|
||||
|
||||
public resizeGroup(position: Position, groupSizeChange: number): void {
|
||||
|
||||
}
|
||||
|
||||
public pinEditor(group: IEditorGroup, input: IEditorInput): void;
|
||||
public pinEditor(position: Position, input: IEditorInput): void;
|
||||
public pinEditor(arg1: any, input: IEditorInput): void {
|
||||
}
|
||||
|
||||
public moveEditor(input: IEditorInput, from: IEditorGroup, to: IEditorGroup, moveOptions?: IMoveOptions): void;
|
||||
public moveEditor(input: IEditorInput, from: Position, to: Position, moveOptions?: IMoveOptions): void;
|
||||
public moveEditor(input: IEditorInput, from: any, to: any, moveOptions?: IMoveOptions): void {
|
||||
}
|
||||
|
||||
public getStacksModel(): EditorStacksModel {
|
||||
return this.stacksModel;
|
||||
}
|
||||
|
||||
public getTabOptions(): IEditorTabOptions {
|
||||
return {};
|
||||
}
|
||||
|
||||
public invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
|
||||
return fn(null);
|
||||
copyGroup(group: number | IEditorGroup, location: number | IEditorGroup, direction: GroupDirection): IEditorGroup {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export class TestEditorService implements IWorkbenchEditorService {
|
||||
public _serviceBrand: any;
|
||||
export class TestEditorGroup implements IEditorGroupView {
|
||||
|
||||
public activeEditorInput: IEditorInput;
|
||||
public activeEditorOptions: IEditorOptions;
|
||||
public activeEditorPosition: Position;
|
||||
public mockLineNumber: number;
|
||||
public mockSelectedText: string;
|
||||
constructor(public id: number) { }
|
||||
|
||||
private callback: (method: string) => void;
|
||||
group: EditorGroup = void 0;
|
||||
activeControl: IEditor;
|
||||
activeEditor: IEditorInput;
|
||||
previewEditor: IEditorInput;
|
||||
count: number;
|
||||
disposed: boolean;
|
||||
editors: ReadonlyArray<IEditorInput> = [];
|
||||
label: string;
|
||||
whenRestored: Promise<void, any> = TPromise.as(void 0);
|
||||
element: HTMLElement;
|
||||
minimumWidth: number;
|
||||
maximumWidth: number;
|
||||
minimumHeight: number;
|
||||
maximumHeight: number;
|
||||
|
||||
constructor(callback?: (method: string) => void) {
|
||||
this.callback = callback || ((s: string) => { });
|
||||
this.mockLineNumber = 15;
|
||||
this.mockSelectedText = 'selected text';
|
||||
}
|
||||
|
||||
public openEditors(inputs: any[]): Promise {
|
||||
return TPromise.as([]);
|
||||
}
|
||||
|
||||
public replaceEditors(editors: any[]): TPromise<IEditor[]> {
|
||||
return TPromise.as([]);
|
||||
}
|
||||
|
||||
public closeEditors(positions?: Position[]): TPromise<void>;
|
||||
public closeEditors(position: Position, filter?: ICloseEditorsFilter): TPromise<void>;
|
||||
public closeEditors(position: Position, editors: IEditorInput[]): TPromise<void>;
|
||||
public closeEditors(editors: { positionOne?: ICloseEditorsFilter, positionTwo?: ICloseEditorsFilter, positionThree?: ICloseEditorsFilter }): TPromise<void>;
|
||||
public closeEditors(editors: { positionOne?: IEditorInput[], positionTwo?: IEditorInput[], positionThree?: IEditorInput[] }): TPromise<void>;
|
||||
public closeEditors(positionOrEditors: any, filterOrEditors?: any): TPromise<void> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
public getActiveEditor(): IEditor {
|
||||
this.callback('getActiveEditor');
|
||||
|
||||
return {
|
||||
input: null,
|
||||
options: null,
|
||||
position: null,
|
||||
getId: () => { return null; },
|
||||
getControl: () => {
|
||||
return {
|
||||
getSelection: () => { return { positionLineNumber: this.mockLineNumber }; },
|
||||
getModel: () => { return { getValueInRange: () => this.mockSelectedText }; }
|
||||
};
|
||||
},
|
||||
focus: () => { },
|
||||
isVisible: () => { return true; }
|
||||
};
|
||||
}
|
||||
|
||||
public getActiveEditorInput(): IEditorInput {
|
||||
this.callback('getActiveEditorInput');
|
||||
|
||||
return this.activeEditorInput;
|
||||
}
|
||||
|
||||
public getVisibleEditors(): IEditor[] {
|
||||
this.callback('getVisibleEditors');
|
||||
onWillDispose: Event<void> = Event.None;
|
||||
onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
|
||||
onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
|
||||
onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
|
||||
onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
|
||||
onDidOpenEditorFail: Event<IEditorInput> = Event.None;
|
||||
onDidFocus: Event<void> = Event.None;
|
||||
onDidChange: Event<{ width: number; height: number; }> = Event.None;
|
||||
|
||||
getEditors(order?: EditorsOrder): ReadonlyArray<IEditorInput> {
|
||||
return [];
|
||||
}
|
||||
|
||||
public openEditor(input: any, options?: any, position?: any): Promise {
|
||||
this.callback('openEditor');
|
||||
getEditor(index: number): IEditorInput {
|
||||
return null;
|
||||
}
|
||||
|
||||
this.activeEditorInput = input;
|
||||
this.activeEditorOptions = options;
|
||||
this.activeEditorPosition = position;
|
||||
getIndexOfEditor(editor: IEditorInput): number {
|
||||
return -1;
|
||||
}
|
||||
|
||||
openEditor(editor: IEditorInput, options?: IEditorOptions): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
openEditors(editors: IEditorInputWithOptions[]): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
isOpened(editor: IEditorInput): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
isPinned(editor: IEditorInput): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
isActive(editor: IEditorInput): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
moveEditor(editor: IEditorInput, target: IEditorGroup, options?: IMoveEditorOptions): void { }
|
||||
|
||||
copyEditor(editor: IEditorInput, target: IEditorGroup, options?: ICopyEditorOptions): void { }
|
||||
|
||||
closeEditor(editor?: IEditorInput): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
closeEditors(editors: IEditorInput[] | { except?: IEditorInput; direction?: CloseDirection; savedOnly?: boolean; }): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
closeAllEditors(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
replaceEditors(editors: IEditorReplacement[]): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
pinEditor(editor?: IEditorInput): void { }
|
||||
|
||||
focus(): void { }
|
||||
|
||||
invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
|
||||
return fn(null);
|
||||
}
|
||||
|
||||
isEmpty(): boolean { return true; }
|
||||
setActive(isActive: boolean): void { }
|
||||
setLabel(label: string): void { }
|
||||
shutdown(): void { }
|
||||
dispose(): void { }
|
||||
toJSON(): object { return Object.create(null); }
|
||||
layout(width: number, height: number): void { }
|
||||
relayout() { }
|
||||
}
|
||||
|
||||
export class TestEditorService implements EditorServiceImpl {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<any>;
|
||||
|
||||
onDidActiveEditorChange: Event<void> = Event.None;
|
||||
onDidVisibleEditorsChange: Event<void> = Event.None;
|
||||
onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
|
||||
onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;
|
||||
|
||||
activeControl: IEditor;
|
||||
activeTextEditorWidget: any;
|
||||
activeEditor: IEditorInput;
|
||||
editors: ReadonlyArray<IEditorInput> = [];
|
||||
visibleControls: ReadonlyArray<IEditor> = [];
|
||||
visibleTextEditorWidgets = [];
|
||||
visibleEditors: ReadonlyArray<IEditorInput> = [];
|
||||
|
||||
overrideOpenEditor(handler: IOpenEditorOverrideHandler): IDisposable {
|
||||
return toDisposable(() => void 0);
|
||||
}
|
||||
|
||||
openEditor(editor: any, options?: any, group?: any) {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
public closeEditor(position: Position, input: IEditorInput): TPromise<void> {
|
||||
this.callback('closeEditor');
|
||||
|
||||
openEditors(editors: any, group?: any) {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
public createInput(input: IResourceInput): IEditorInput {
|
||||
isOpen(editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
replaceEditors(editors: any, group: any) {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
|
||||
return fn(null);
|
||||
}
|
||||
|
||||
createInput(input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -769,10 +854,6 @@ export class TestFileService implements IFileService {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
rename(resource: URI, newName: string): TPromise<IFileStat> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
onDidChangeFileSystemProviderRegistrations = Event.None;
|
||||
|
||||
registerProvider(scheme: string, provider) {
|
||||
@@ -783,7 +864,7 @@ export class TestFileService implements IFileService {
|
||||
return resource.scheme === 'file';
|
||||
}
|
||||
|
||||
del(resource: URI, useTrash?: boolean): TPromise<void> {
|
||||
del(resource: URI, options?: { useTrash?: boolean, recursive?: boolean }): TPromise<void> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
@@ -804,8 +885,6 @@ export class TestFileService implements IFileService {
|
||||
export class TestBackupFileService implements IBackupFileService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
public backupEnabled: boolean;
|
||||
|
||||
public hasBackups(): TPromise<boolean> {
|
||||
return TPromise.as(false);
|
||||
}
|
||||
@@ -864,16 +943,45 @@ export class TestBackupFileService implements IBackupFileService {
|
||||
}
|
||||
}
|
||||
|
||||
export class TestCodeEditorService implements ICodeEditorService {
|
||||
_serviceBrand: any;
|
||||
|
||||
onCodeEditorAdd: Event<ICodeEditor> = Event.None;
|
||||
onCodeEditorRemove: Event<ICodeEditor> = Event.None;
|
||||
onDiffEditorAdd: Event<IDiffEditor> = Event.None;
|
||||
onDiffEditorRemove: Event<IDiffEditor> = Event.None;
|
||||
|
||||
addCodeEditor(editor: ICodeEditor): void { }
|
||||
removeCodeEditor(editor: ICodeEditor): void { }
|
||||
listCodeEditors(): ICodeEditor[] { return []; }
|
||||
addDiffEditor(editor: IDiffEditor): void { }
|
||||
removeDiffEditor(editor: IDiffEditor): void { }
|
||||
listDiffEditors(): IDiffEditor[] { return []; }
|
||||
getFocusedCodeEditor(): ICodeEditor { return null; }
|
||||
registerDecorationType(key: string, options: IDecorationRenderOptions, parentTypeKey?: string): void { }
|
||||
removeDecorationType(key: string): void { }
|
||||
resolveDecorationOptions(typeKey: string, writable: boolean): IModelDecorationOptions { return Object.create(null); }
|
||||
setTransientModelProperty(model: ITextModel, key: string, value: any): void { }
|
||||
getTransientModelProperty(model: ITextModel, key: string) { }
|
||||
getActiveCodeEditor(): ICodeEditor { return null; }
|
||||
openCodeEditor(input: IResourceInput, source: ICodeEditor, sideBySide?: boolean): TPromise<ICodeEditor> { return TPromise.as(null); }
|
||||
}
|
||||
|
||||
export class TestWindowService implements IWindowService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
|
||||
onDidChangeMaximize: Event<boolean>;
|
||||
|
||||
isFocused(): TPromise<boolean> {
|
||||
return TPromise.as(false);
|
||||
}
|
||||
|
||||
isMaximized(): TPromise<boolean> {
|
||||
return TPromise.as(false);
|
||||
}
|
||||
|
||||
getConfiguration(): IWindowConfiguration {
|
||||
return Object.create(null);
|
||||
}
|
||||
@@ -914,6 +1022,10 @@ export class TestWindowService implements IWindowService {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
enterWorkspace(path: string): TPromise<IEnterWorkspaceResult> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
@@ -938,6 +1050,22 @@ export class TestWindowService implements IWindowService {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
maximizeWindow(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
unmaximizeWindow(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
minimizeWindow(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
openWindow(paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
closeWindow(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
@@ -966,7 +1094,7 @@ export class TestWindowService implements IWindowService {
|
||||
return TPromise.wrap(void 0);
|
||||
}
|
||||
|
||||
updateTouchBar(items: ICommandAction[][]): Promise<void> {
|
||||
updateTouchBar(items: ISerializableCommandAction[][]): Promise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
}
|
||||
@@ -981,7 +1109,7 @@ export class TestLifecycleService implements ILifecycleService {
|
||||
private _onWillShutdown = new Emitter<ShutdownEvent>();
|
||||
private _onShutdown = new Emitter<ShutdownReason>();
|
||||
|
||||
when(): Thenable<void> {
|
||||
when(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
@@ -1011,6 +1139,9 @@ export class TestWindowsService implements IWindowsService {
|
||||
onWindowOpen: Event<number>;
|
||||
onWindowFocus: Event<number>;
|
||||
onWindowBlur: Event<number>;
|
||||
onWindowMaximize: Event<number>;
|
||||
onWindowUnmaximize: Event<number>;
|
||||
onRecentlyOpenedChange: Event<void>;
|
||||
|
||||
isFocused(windowId: number): TPromise<boolean> {
|
||||
return TPromise.as(false);
|
||||
@@ -1048,6 +1179,10 @@ export class TestWindowsService implements IWindowsService {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
enterWorkspace(windowId: number, path: string): TPromise<IEnterWorkspaceResult> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
@@ -1096,6 +1231,10 @@ export class TestWindowsService implements IWindowsService {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
minimizeWindow(windowId: number): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
unmaximizeWindow(windowId: number): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
@@ -1125,7 +1264,7 @@ export class TestWindowsService implements IWindowsService {
|
||||
}
|
||||
|
||||
// Global methods
|
||||
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
|
||||
openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
@@ -1137,7 +1276,7 @@ export class TestWindowsService implements IWindowsService {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]> {
|
||||
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
@@ -1173,10 +1312,14 @@ export class TestWindowsService implements IWindowsService {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
updateTouchBar(windowId: number, items: ICommandAction[][]): Promise<void> {
|
||||
updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): Promise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
getActiveWindowId(): TPromise<number | undefined> {
|
||||
return TPromise.as(undefined);
|
||||
}
|
||||
|
||||
// This needs to be handled from browser process to prevent
|
||||
// foreground ordering issues on Windows
|
||||
openExternal(url: string): TPromise<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user