mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 18:46:34 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -10,13 +10,6 @@ import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { prepareActions } from 'vs/workbench/browser/actions';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
|
||||
|
||||
class MyClass extends Action {
|
||||
constructor(id: string, label: string) {
|
||||
super(id, label);
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench Action Registry', () => {
|
||||
|
||||
test('Workbench Action Bar prepareActions()', function () {
|
||||
|
||||
@@ -70,12 +70,12 @@ class MyInputFactory implements IEditorInputFactory {
|
||||
}
|
||||
|
||||
deserialize(instantiationService: IInstantiationService, raw: string): EditorInput {
|
||||
return <EditorInput>{};
|
||||
return {} as EditorInput;
|
||||
}
|
||||
}
|
||||
|
||||
class MyInput extends EditorInput {
|
||||
getPreferredEditorId(ids) {
|
||||
getPreferredEditorId(ids: string[]) {
|
||||
return ids[1];
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,12 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Position, Direction } from 'vs/platform/editor/common/editor';
|
||||
import { Position, Direction, IEditorModel } from 'vs/platform/editor/common/editor';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
function create(): EditorStacksModel {
|
||||
let inst = new TestInstantiationService();
|
||||
@@ -60,7 +61,7 @@ interface GroupEvents {
|
||||
}
|
||||
|
||||
function modelListener(model: EditorStacksModel): ModelEvents {
|
||||
const modelEvents = {
|
||||
const modelEvents: ModelEvents = {
|
||||
opened: [],
|
||||
activated: [],
|
||||
closed: [],
|
||||
@@ -86,7 +87,7 @@ function modelListener(model: EditorStacksModel): ModelEvents {
|
||||
}
|
||||
|
||||
function groupListener(group: EditorGroup): GroupEvents {
|
||||
const groupEvents = {
|
||||
const groupEvents: GroupEvents = {
|
||||
opened: [],
|
||||
closed: [],
|
||||
activated: [],
|
||||
@@ -111,7 +112,7 @@ class TestEditorInput extends EditorInput {
|
||||
super();
|
||||
}
|
||||
public getTypeId() { return 'testEditorInput'; }
|
||||
public resolve() { return null; }
|
||||
public resolve(): TPromise<IEditorModel> { return null; }
|
||||
|
||||
public matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
@@ -131,7 +132,7 @@ class NonSerializableTestEditorInput extends EditorInput {
|
||||
super();
|
||||
}
|
||||
public getTypeId() { return 'testEditorInput-nonSerializable'; }
|
||||
public resolve() { return null; }
|
||||
public resolve(): TPromise<IEditorModel> { return null; }
|
||||
|
||||
public matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof NonSerializableTestEditorInput;
|
||||
@@ -144,7 +145,7 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput {
|
||||
super();
|
||||
}
|
||||
public getTypeId() { return 'testFileEditorInput'; }
|
||||
public resolve() { return null; }
|
||||
public resolve(): TPromise<IEditorModel> { return null; }
|
||||
|
||||
public matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestFileEditorInput;
|
||||
@@ -364,6 +365,7 @@ suite('Editor Stacks Model', () => {
|
||||
|
||||
model.moveGroup(group3, 1);
|
||||
assert.equal(events.moved.length, 2);
|
||||
assert.ok(group2);
|
||||
});
|
||||
|
||||
test('Groups - Event Aggregation', function () {
|
||||
@@ -504,7 +506,7 @@ suite('Editor Stacks Model', () => {
|
||||
assert.equal(group.activeEditor, void 0);
|
||||
assert.equal(events.closed[0].editor, input1);
|
||||
assert.equal(events.closed[0].index, 0);
|
||||
assert.equal(events.closed[0].pinned, true);
|
||||
assert.equal(events.closed[0].replaced, false);
|
||||
|
||||
// Active && Preview
|
||||
const input2 = input();
|
||||
@@ -527,7 +529,7 @@ suite('Editor Stacks Model', () => {
|
||||
assert.equal(group.activeEditor, void 0);
|
||||
assert.equal(events.closed[1].editor, input2);
|
||||
assert.equal(events.closed[1].index, 0);
|
||||
assert.equal(events.closed[1].pinned, false);
|
||||
assert.equal(events.closed[1].replaced, false);
|
||||
|
||||
group.closeEditor(input2);
|
||||
assert.equal(group.count, 0);
|
||||
@@ -746,6 +748,8 @@ suite('Editor Stacks Model', () => {
|
||||
assert.equal(events.opened[2], input3);
|
||||
assert.equal(events.closed[0].editor, input1);
|
||||
assert.equal(events.closed[1].editor, input2);
|
||||
assert.equal(events.closed[0].replaced, true);
|
||||
assert.equal(events.closed[1].replaced, true);
|
||||
|
||||
const mru = group.getEditors(true);
|
||||
assert.equal(mru[0], input3);
|
||||
@@ -1497,6 +1501,13 @@ suite('Editor Stacks Model', () => {
|
||||
previous = model.previous(true /* jump groups */);
|
||||
assert.equal(previous.group, group1);
|
||||
assert.equal(previous.editor, input3);
|
||||
|
||||
model.setActive(<EditorGroup>previous.group);
|
||||
(<EditorGroup>next.group).setActive(<EditorInput>previous.editor);
|
||||
|
||||
const last = model.last();
|
||||
assert.equal(last.group, group1);
|
||||
assert.equal(last.editor, input3);
|
||||
});
|
||||
|
||||
test('Stack - Multiple Editors - Navigation (in group)', function () {
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
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 { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
|
||||
import WorkbenchEditorService = require('vs/workbench/services/editor/common/editorService');
|
||||
import { RangeHighlightDecorations } from 'vs/workbench/browser/parts/editor/rangeDecorations';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
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 { TextModel } from 'vs/editor/common/model/textModel';
|
||||
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';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { CoreNavigationCommands } from 'vs/editor/browser/controller/coreCommands';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
suite('Editor - Range decorations', () => {
|
||||
|
||||
let instantiationService: TestInstantiationService;
|
||||
let codeEditor: ICodeEditor;
|
||||
let model: Model;
|
||||
let text: string;
|
||||
let testObject: RangeHighlightDecorations;
|
||||
let modelsToDispose: Model[] = [];
|
||||
|
||||
setup(() => {
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
instantiationService.stub(WorkbenchEditorService.IWorkbenchEditorService, 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);
|
||||
|
||||
instantiationService.stub(WorkbenchEditorService.IWorkbenchEditorService, 'getActiveEditor', { getControl: () => { return codeEditor; } });
|
||||
|
||||
testObject = instantiationService.createInstance(RangeHighlightDecorations);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
codeEditor.dispose();
|
||||
modelsToDispose.forEach(model => model.dispose());
|
||||
});
|
||||
|
||||
test('highlight range for the resource if it is an active editor', function () {
|
||||
let range: IRange = { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 };
|
||||
testObject.highlightRange({ resource: model.uri, range });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
|
||||
assert.deepEqual([range], actuals);
|
||||
});
|
||||
|
||||
test('remove highlight range', function () {
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
testObject.removeHighlightRange();
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
|
||||
assert.deepEqual([], actuals);
|
||||
});
|
||||
|
||||
test('highlight range for the resource removes previous highlight', function () {
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
let range: IRange = { startLineNumber: 2, startColumn: 2, endLineNumber: 4, endColumn: 3 };
|
||||
testObject.highlightRange({ resource: model.uri, range });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
|
||||
assert.deepEqual([range], actuals);
|
||||
});
|
||||
|
||||
test('highlight range for a new resource removes highlight of previous resource', function () {
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
|
||||
let anotherModel = prepareActiveEditor('anotherModel');
|
||||
let range: IRange = { startLineNumber: 2, startColumn: 2, endLineNumber: 4, endColumn: 3 };
|
||||
testObject.highlightRange({ resource: anotherModel.uri, range });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([], actuals);
|
||||
actuals = rangeHighlightDecorations(anotherModel);
|
||||
assert.deepEqual([range], actuals);
|
||||
});
|
||||
|
||||
test('highlight is removed on model change', function () {
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
prepareActiveEditor('anotherModel');
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([], actuals);
|
||||
});
|
||||
|
||||
test('highlight is removed on cursor position change', function () {
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
codeEditor.trigger('mouse', CoreNavigationCommands.MoveTo.id, {
|
||||
position: new Position(2, 1)
|
||||
});
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([], actuals);
|
||||
});
|
||||
|
||||
test('range is not highlight if not active editor', function () {
|
||||
let model = aModel(URI.file('some model'));
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([], actuals);
|
||||
});
|
||||
|
||||
test('previous highlight is not removed if not active editor', function () {
|
||||
let range: IRange = { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 };
|
||||
testObject.highlightRange({ resource: model.uri, range });
|
||||
|
||||
let model1 = aModel(URI.file('some model'));
|
||||
testObject.highlightRange({ resource: model1.uri, range: { startLineNumber: 2, startColumn: 1, endLineNumber: 2, endColumn: 1 } });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([range], actuals);
|
||||
});
|
||||
|
||||
function prepareActiveEditor(resource: string): Model {
|
||||
let model = aModel(URI.file(resource));
|
||||
codeEditor.setModel(model);
|
||||
mockEditorService(model.uri);
|
||||
return model;
|
||||
}
|
||||
|
||||
function aModel(resource: URI, content: string = text): Model {
|
||||
let model = Model.createFromString(content, TextModel.DEFAULT_CREATION_OPTIONS, null, resource);
|
||||
modelsToDispose.push(model);
|
||||
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: Model): IRange[] {
|
||||
let rangeHighlights: IRange[] = [];
|
||||
|
||||
for (let dec of m.getAllDecorations()) {
|
||||
if (dec.options.className === 'rangeHighlight') {
|
||||
rangeHighlights.push(dec.range);
|
||||
}
|
||||
}
|
||||
|
||||
rangeHighlights.sort(Range.compareRangesUsingStarts);
|
||||
return rangeHighlights;
|
||||
}
|
||||
|
||||
function stubModelService(instantiationService: TestInstantiationService): IModelService {
|
||||
instantiationService.stub(IConfigurationService, new TestConfigurationService());
|
||||
return instantiationService.createInstance(ModelServiceImpl);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user