mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
Merge from vscode 79a1f5a5ca0c6c53db617aa1fa5a2396d2caebe2
This commit is contained in:
@@ -30,7 +30,7 @@ import { ITextModel } from 'vs/editor/common/model';
|
||||
import { nullExtensionDescription, IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { NullApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { MainThreadCommandsShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
suite('ExtHostCommands', function () {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfigurat
|
||||
import { MainThreadConfigurationShape, IConfigurationInitData } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ConfigurationModel, ConfigurationModelParser } from 'vs/platform/configuration/common/configurationModels';
|
||||
import { TestRPCProtocol } from './testRPCProtocol';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { IWorkspaceFolder, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { ConfigurationTarget, IConfigurationModel, IConfigurationChange } from 'vs/platform/configuration/common/configuration';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
@@ -9,7 +9,7 @@ import { DiagnosticCollection, ExtHostDiagnostics } from 'vs/workbench/api/commo
|
||||
import { Diagnostic, DiagnosticSeverity, Range, DiagnosticRelatedInformation, Location } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { MainThreadDiagnosticsShape, IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import type * as vscode from 'vscode';
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Position } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { MainThreadDocumentsShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/model/mirrorTextModel';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
|
||||
|
||||
suite('ExtHostDocumentData', () => {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { ExtHostDocumentSaveParticipant } from 'vs/workbench/api/common/extHostD
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { SaveReason } from 'vs/workbench/common/editor';
|
||||
import type * as vscode from 'vscode';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
@@ -43,7 +43,7 @@ import { getColors } from 'vs/editor/contrib/colorPicker/color';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { nullExtensionDescription as defaultExtension } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { provideSelectionRanges } from 'vs/editor/contrib/smartSelect/smartSelect';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
@@ -762,6 +762,72 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
assert.equal(value.edits.length, 2);
|
||||
});
|
||||
|
||||
test('Multiple RenameProviders don\'t respect all possible PrepareRename handlers, #98352', async function () {
|
||||
|
||||
let called = [false, false, false, false];
|
||||
|
||||
disposables.push(extHost.registerRenameProvider(defaultExtension, defaultSelector, new class implements vscode.RenameProvider {
|
||||
prepareRename(document: vscode.TextDocument, position: vscode.Position,): vscode.ProviderResult<vscode.Range> {
|
||||
called[0] = true;
|
||||
let range = document.getWordRangeAtPosition(position);
|
||||
return range;
|
||||
}
|
||||
|
||||
provideRenameEdits(): vscode.ProviderResult<vscode.WorkspaceEdit> {
|
||||
called[1] = true;
|
||||
return undefined;
|
||||
}
|
||||
}));
|
||||
|
||||
disposables.push(extHost.registerRenameProvider(defaultExtension, defaultSelector, new class implements vscode.RenameProvider {
|
||||
prepareRename(document: vscode.TextDocument, position: vscode.Position,): vscode.ProviderResult<vscode.Range> {
|
||||
called[2] = true;
|
||||
return Promise.reject('Cannot rename this symbol2.');
|
||||
}
|
||||
provideRenameEdits(): vscode.ProviderResult<vscode.WorkspaceEdit> {
|
||||
called[3] = true;
|
||||
return undefined;
|
||||
}
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
await rename(model, new EditorPosition(1, 1), 'newName');
|
||||
|
||||
assert.deepEqual(called, [true, true, true, false]);
|
||||
});
|
||||
|
||||
test('Multiple RenameProviders don\'t respect all possible PrepareRename handlers, #98352', async function () {
|
||||
|
||||
let called = [false, false, false];
|
||||
|
||||
disposables.push(extHost.registerRenameProvider(defaultExtension, defaultSelector, new class implements vscode.RenameProvider {
|
||||
prepareRename(document: vscode.TextDocument, position: vscode.Position,): vscode.ProviderResult<vscode.Range> {
|
||||
called[0] = true;
|
||||
let range = document.getWordRangeAtPosition(position);
|
||||
return range;
|
||||
}
|
||||
|
||||
provideRenameEdits(): vscode.ProviderResult<vscode.WorkspaceEdit> {
|
||||
called[1] = true;
|
||||
return undefined;
|
||||
}
|
||||
}));
|
||||
|
||||
disposables.push(extHost.registerRenameProvider(defaultExtension, defaultSelector, new class implements vscode.RenameProvider {
|
||||
|
||||
provideRenameEdits(document: vscode.TextDocument, position: vscode.Position, newName: string,): vscode.ProviderResult<vscode.WorkspaceEdit> {
|
||||
called[2] = true;
|
||||
return new types.WorkspaceEdit();
|
||||
}
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
await rename(model, new EditorPosition(1, 1), 'newName');
|
||||
|
||||
// first provider has NO prepare which means it is taken by default
|
||||
assert.deepEqual(called, [false, false, true]);
|
||||
});
|
||||
|
||||
// --- parameter hints
|
||||
|
||||
test('Parameter Hints, order', async () => {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { MainThreadMessageService } from 'vs/workbench/api/browser/mainThreadMes
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { INotificationService, INotification, NoOpNotification, INotificationHandle, Severity, IPromptChoice, IPromptOptions, IStatusMessageOptions, NotificationsFilter } from 'vs/platform/notification/common/notification';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ suite('NotebookConcatDocument', function () {
|
||||
});
|
||||
extHostDocumentsAndEditors = new ExtHostDocumentsAndEditors(rpcProtocol, new NullLogService());
|
||||
extHostDocuments = new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors);
|
||||
extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors);
|
||||
extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, { isExtensionDevelopmentDebug: false, webviewCspSource: '', webviewResourceRoot: '' });
|
||||
let reg = extHostNotebooks.registerNotebookContentProvider(nullExtensionDescription, 'test', new class extends mock<vscode.NotebookContentProvider>() {
|
||||
// async openNotebook() { }
|
||||
});
|
||||
@@ -52,22 +52,26 @@ suite('NotebookConcatDocument', function () {
|
||||
addedDocuments: [{
|
||||
handle: 0,
|
||||
uri: notebookUri,
|
||||
viewType: 'test'
|
||||
}]
|
||||
viewType: 'test',
|
||||
cells: [{
|
||||
handle: 0,
|
||||
uri: CellUri.generate(notebookUri, 0),
|
||||
source: ['### Heading'],
|
||||
language: 'markdown',
|
||||
cellKind: CellKind.Markdown,
|
||||
outputs: [],
|
||||
}],
|
||||
versionId: 0
|
||||
}],
|
||||
addedEditors: [
|
||||
{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_0',
|
||||
selections: [0]
|
||||
}
|
||||
]
|
||||
});
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: 0,
|
||||
changes: [[0, 0, [{
|
||||
handle: 0,
|
||||
uri: CellUri.generate(notebookUri, 0),
|
||||
source: ['### Heading'],
|
||||
language: 'markdown',
|
||||
cellKind: CellKind.Markdown,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
await extHostNotebooks.$acceptDocumentAndEditorsDelta({ newActiveEditor: notebookUri });
|
||||
await extHostNotebooks.$acceptDocumentAndEditorsDelta({ newActiveEditor: '_notebook_editor_0' });
|
||||
|
||||
notebook = extHostNotebooks.activeNotebookDocument!;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { MainThreadTextEditorsShape, IResolvedTextEditorConfiguration, ITextEdit
|
||||
import { ExtHostTextEditorOptions, ExtHostTextEditor } from 'vs/workbench/api/common/extHostTextEditor';
|
||||
import { ExtHostDocumentData } from 'vs/workbench/api/common/extHostDocumentData';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
suite('ExtHostTextEditor', () => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as assert from 'assert';
|
||||
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
||||
import { MainContext, MainThreadTextEditorsShape, IWorkspaceEditDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { SingleProxyRPCProtocol, TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
|
||||
import { ExtHostEditors } from 'vs/workbench/api/common/extHostTextEditors';
|
||||
|
||||
@@ -14,7 +14,7 @@ import { TestRPCProtocol } from './testRPCProtocol';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { TreeItemCollapsibleState, ITreeItem } from 'vs/workbench/common/views';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
@@ -11,7 +11,7 @@ import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { MainThreadWebviews } from 'vs/workbench/api/browser/mainThreadWebview';
|
||||
import { ExtHostWebviews } from 'vs/workbench/api/common/extHostWebview';
|
||||
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
||||
|
||||
@@ -14,7 +14,7 @@ import { MainThreadWorkspace } from 'vs/workbench/api/browser/mainThreadWorkspac
|
||||
import { IMainContext, IWorkspaceData, MainContext, ITextSearchComplete } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { RelativePattern } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { TestRPCProtocol } from './testRPCProtocol';
|
||||
import { ExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
|
||||
@@ -8,7 +8,7 @@ import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands'
|
||||
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
|
||||
suite('MainThreadCommands', function () {
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import { MarkerService } from 'vs/platform/markers/common/markerService';
|
||||
import { MainThreadDiagnostics } from 'vs/workbench/api/browser/mainThreadDiagnostics';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { mock } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
|
||||
|
||||
|
||||
suite('MainThreadDiagnostics', function () {
|
||||
@@ -20,16 +22,22 @@ suite('MainThreadDiagnostics', function () {
|
||||
|
||||
test('clear markers on dispose', function () {
|
||||
|
||||
let diag = new MainThreadDiagnostics(new class implements IExtHostContext {
|
||||
remoteAuthority = '';
|
||||
assertRegistered() { }
|
||||
set(v: any): any { return null; }
|
||||
getProxy(): any {
|
||||
return {
|
||||
$acceptMarkersChange() { }
|
||||
};
|
||||
let diag = new MainThreadDiagnostics(
|
||||
new class implements IExtHostContext {
|
||||
remoteAuthority = '';
|
||||
assertRegistered() { }
|
||||
set(v: any): any { return null; }
|
||||
getProxy(): any {
|
||||
return {
|
||||
$acceptMarkersChange() { }
|
||||
};
|
||||
}
|
||||
},
|
||||
markerService,
|
||||
new class extends mock<IUriIdentityService>() {
|
||||
asCanonicalUri(uri: URI) { return uri; }
|
||||
}
|
||||
}, markerService);
|
||||
);
|
||||
|
||||
diag.$changeMany('foo', [[URI.file('a'), [{
|
||||
code: '666',
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { MainThreadDocumentContentProviders } from 'vs/workbench/api/browser/mainThreadDocumentContentProviders';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
|
||||
|
||||
@@ -7,6 +7,7 @@ import * as assert from 'assert';
|
||||
import { BoundModelReferenceCollection } from 'vs/workbench/api/browser/mainThreadDocuments';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
suite('BoundModelReferenceCollection', () => {
|
||||
|
||||
@@ -20,12 +21,14 @@ suite('BoundModelReferenceCollection', () => {
|
||||
|
||||
let didDispose = false;
|
||||
|
||||
col.add({
|
||||
object: <any>{ textEditorModel: createTextModel('farboo') },
|
||||
dispose() {
|
||||
didDispose = true;
|
||||
}
|
||||
});
|
||||
col.add(
|
||||
URI.parse('test://farboo'),
|
||||
{
|
||||
object: <any>{ textEditorModel: createTextModel('farboo') },
|
||||
dispose() {
|
||||
didDispose = true;
|
||||
}
|
||||
});
|
||||
|
||||
await timeout(30);
|
||||
assert.equal(didDispose, true);
|
||||
@@ -35,27 +38,95 @@ suite('BoundModelReferenceCollection', () => {
|
||||
|
||||
let disposed: number[] = [];
|
||||
|
||||
col.add({
|
||||
object: <any>{ textEditorModel: createTextModel('farboo') },
|
||||
dispose() {
|
||||
disposed.push(0);
|
||||
}
|
||||
});
|
||||
col.add({
|
||||
object: <any>{ textEditorModel: createTextModel('boofar') },
|
||||
dispose() {
|
||||
disposed.push(1);
|
||||
}
|
||||
});
|
||||
col.add(
|
||||
URI.parse('test://farboo'),
|
||||
{
|
||||
object: <any>{ textEditorModel: createTextModel('farboo') },
|
||||
dispose() {
|
||||
disposed.push(0);
|
||||
}
|
||||
});
|
||||
|
||||
col.add({
|
||||
object: <any>{ textEditorModel: createTextModel(new Array(71).join('x')) },
|
||||
dispose() {
|
||||
disposed.push(2);
|
||||
}
|
||||
});
|
||||
col.add(
|
||||
URI.parse('test://boofar'),
|
||||
{
|
||||
object: <any>{ textEditorModel: createTextModel('boofar') },
|
||||
dispose() {
|
||||
disposed.push(1);
|
||||
}
|
||||
});
|
||||
|
||||
col.add(
|
||||
URI.parse('test://xxxxxxx'),
|
||||
{
|
||||
object: <any>{ textEditorModel: createTextModel(new Array(71).join('x')) },
|
||||
dispose() {
|
||||
disposed.push(2);
|
||||
}
|
||||
});
|
||||
|
||||
assert.deepEqual(disposed, [0, 1]);
|
||||
});
|
||||
|
||||
test('dispose uri', () => {
|
||||
|
||||
let disposed: number[] = [];
|
||||
|
||||
col.add(
|
||||
URI.parse('test:///farboo'),
|
||||
{
|
||||
object: <any>{ textEditorModel: createTextModel('farboo') },
|
||||
dispose() {
|
||||
disposed.push(0);
|
||||
}
|
||||
});
|
||||
|
||||
col.add(
|
||||
URI.parse('test:///boofar'),
|
||||
{
|
||||
object: <any>{ textEditorModel: createTextModel('boofar') },
|
||||
dispose() {
|
||||
disposed.push(1);
|
||||
}
|
||||
});
|
||||
|
||||
col.add(
|
||||
URI.parse('test:///boo/far1'),
|
||||
{
|
||||
object: <any>{ textEditorModel: createTextModel('boo/far1') },
|
||||
dispose() {
|
||||
disposed.push(2);
|
||||
}
|
||||
});
|
||||
|
||||
col.add(
|
||||
URI.parse('test:///boo/far2'),
|
||||
{
|
||||
object: <any>{ textEditorModel: createTextModel('boo/far2') },
|
||||
dispose() {
|
||||
disposed.push(3);
|
||||
}
|
||||
});
|
||||
|
||||
col.add(
|
||||
URI.parse('test:///boo1/far'),
|
||||
{
|
||||
object: <any>{ textEditorModel: createTextModel('boo1/far') },
|
||||
dispose() {
|
||||
disposed.push(4);
|
||||
}
|
||||
});
|
||||
|
||||
col.remove(URI.parse('test:///unknown'));
|
||||
assert.equal(disposed.length, 0);
|
||||
|
||||
col.remove(URI.parse('test:///farboo'));
|
||||
assert.deepEqual(disposed, [0]);
|
||||
|
||||
disposed = [];
|
||||
|
||||
col.remove(URI.parse('test:///boo'));
|
||||
assert.deepEqual(disposed, [2, 3]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -11,8 +11,8 @@ import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { TestCodeEditorService } from 'vs/editor/test/browser/editorTestServices';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ExtHostDocumentsAndEditorsShape, IDocumentsAndEditorsDelta } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { createTestCodeEditor, TestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { createTestCodeEditor, ITestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { TestEditorService, TestEditorGroupsService, TestEnvironmentService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
@@ -25,7 +25,8 @@ import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { TestTextResourcePropertiesService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { TestTextResourcePropertiesService, TestWorkingCopyFileService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentityService';
|
||||
|
||||
suite('MainThreadDocumentsAndEditors', () => {
|
||||
|
||||
@@ -35,7 +36,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
let deltas: IDocumentsAndEditorsDelta[] = [];
|
||||
const hugeModelString = new Array(2 + (50 * 1024 * 1024)).join('-');
|
||||
|
||||
function myCreateTestCodeEditor(model: ITextModel | undefined): TestCodeEditor {
|
||||
function myCreateTestCodeEditor(model: ITextModel | undefined): ITestCodeEditor {
|
||||
return createTestCodeEditor({
|
||||
model: model,
|
||||
serviceCollection: new ServiceCollection(
|
||||
@@ -88,7 +89,9 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
TestEnvironmentService
|
||||
TestEnvironmentService,
|
||||
new TestWorkingCopyFileService(),
|
||||
new UriIdentityService(fileService),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { TestCodeEditorService } from 'vs/editor/test/browser/editorTestServices';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ExtHostDocumentsAndEditorsShape, ExtHostContext, ExtHostDocumentsShape, IWorkspaceTextEditDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { MainThreadTextEditors } from 'vs/workbench/api/browser/mainThreadEditors';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
@@ -104,6 +104,7 @@ suite('MainThreadEditors', () => {
|
||||
};
|
||||
});
|
||||
services.set(IWorkingCopyFileService, new class extends mock<IWorkingCopyFileService>() {
|
||||
onDidRunWorkingCopyFileOperation = Event.None;
|
||||
move(source: URI, target: URI) {
|
||||
movedResources.set(source, target);
|
||||
return Promise.resolve(Object.create(null));
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export interface Ctor<T> {
|
||||
new(): T;
|
||||
}
|
||||
|
||||
export function mock<T>(): Ctor<T> {
|
||||
return function () { } as any;
|
||||
}
|
||||
@@ -79,6 +79,8 @@ interface GroupEvents {
|
||||
closed: EditorCloseEvent[];
|
||||
pinned: EditorInput[];
|
||||
unpinned: EditorInput[];
|
||||
sticky: EditorInput[];
|
||||
unsticky: EditorInput[];
|
||||
moved: EditorInput[];
|
||||
disposed: EditorInput[];
|
||||
}
|
||||
@@ -90,6 +92,8 @@ function groupListener(group: EditorGroup): GroupEvents {
|
||||
activated: [],
|
||||
pinned: [],
|
||||
unpinned: [],
|
||||
sticky: [],
|
||||
unsticky: [],
|
||||
moved: [],
|
||||
disposed: []
|
||||
};
|
||||
@@ -98,6 +102,7 @@ function groupListener(group: EditorGroup): GroupEvents {
|
||||
group.onDidCloseEditor(e => groupEvents.closed.push(e));
|
||||
group.onDidActivateEditor(e => groupEvents.activated.push(e));
|
||||
group.onDidChangeEditorPinned(e => group.isPinned(e) ? groupEvents.pinned.push(e) : groupEvents.unpinned.push(e));
|
||||
group.onDidChangeEditorSticky(e => group.isSticky(e) ? groupEvents.sticky.push(e) : groupEvents.unsticky.push(e));
|
||||
group.onDidMoveEditor(e => groupEvents.moved.push(e));
|
||||
group.onDidDisposeEditor(e => groupEvents.disposed.push(e));
|
||||
|
||||
@@ -609,6 +614,12 @@ suite('Workbench editor groups', () => {
|
||||
group.pin(sameInput1);
|
||||
assert.equal(events.pinned[0], input1);
|
||||
|
||||
group.stick(sameInput1);
|
||||
assert.equal(events.sticky[0], input1);
|
||||
|
||||
group.unstick(sameInput1);
|
||||
assert.equal(events.unsticky[0], input1);
|
||||
|
||||
group.moveEditor(sameInput1, 1);
|
||||
assert.equal(events.moved[0], input1);
|
||||
|
||||
|
||||
@@ -107,6 +107,8 @@ import { TestWorkingCopyService, TestContextService, TestStorageService, TestTex
|
||||
import { IViewsService, IView, ViewContainer, ViewContainerLocation } from 'vs/workbench/common/views';
|
||||
import { IStorageKeysSyncRegistryService, StorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
|
||||
import { IPaneComposite } from 'vs/workbench/common/panecomposite';
|
||||
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
|
||||
import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentityService';
|
||||
|
||||
export function createFileEditorInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
|
||||
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined);
|
||||
@@ -149,7 +151,9 @@ export function workbenchInstantiationService(overrides?: {
|
||||
const themeService = new TestThemeService();
|
||||
instantiationService.stub(IThemeService, themeService);
|
||||
instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
|
||||
instantiationService.stub(IFileService, new TestFileService());
|
||||
const fileService = new TestFileService();
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
instantiationService.stub(IUriIdentityService, new UriIdentityService(fileService));
|
||||
instantiationService.stub(IBackupFileService, new TestBackupFileService());
|
||||
instantiationService.stub(ITelemetryService, NullTelemetryService);
|
||||
instantiationService.stub(INotificationService, new TestNotificationService());
|
||||
@@ -670,6 +674,7 @@ export class TestEditorService implements EditorServiceImpl {
|
||||
saveAll(options?: ISaveEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
|
||||
revert(editors: IEditorIdentifier[], options?: IRevertOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
|
||||
revertAll(options?: IRevertAllEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
|
||||
whenClosed(resources: URI[], options?: { waitForSaved: boolean }): Promise<void> { throw new Error('Method not implemented.'); }
|
||||
}
|
||||
|
||||
export class TestFileService implements IFileService {
|
||||
|
||||
Reference in New Issue
Block a user