mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 4636be2b71c87bfb0bfe3c94278b447a5efcc1f1 (#8722)
* Merge from vscode 4636be2b71c87bfb0bfe3c94278b447a5efcc1f1 * remove tests that aren't working
This commit is contained in:
@@ -7,7 +7,7 @@ import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { isUndefinedOrNull, withNullAsUndefined, assertIsDefined } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IEditor as ICodeEditor, IEditorViewState, ScrollType, IDiffEditor } from 'vs/editor/common/editorCommon';
|
||||
import { IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, IResourceInput, EditorActivation, EditorOpenContext } from 'vs/platform/editor/common/editor';
|
||||
import { IInstantiationService, IConstructorSignature0, ServicesAccessor, BrandedService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -181,7 +181,7 @@ export interface IEditorInputFactoryRegistry {
|
||||
* @param editorInputId the identifier of the editor input
|
||||
* @param factory the editor input factory for serialization/deserialization
|
||||
*/
|
||||
registerEditorInputFactory<Services extends BrandedService[]>(editorInputId: string, ctor: { new(...Services: Services): IEditorInputFactory }): void;
|
||||
registerEditorInputFactory<Services extends BrandedService[]>(editorInputId: string, ctor: { new(...Services: Services): IEditorInputFactory }): IDisposable;
|
||||
|
||||
/**
|
||||
* Returns the editor input factory for the given editor input.
|
||||
@@ -198,6 +198,11 @@ export interface IEditorInputFactoryRegistry {
|
||||
|
||||
export interface IEditorInputFactory {
|
||||
|
||||
/**
|
||||
* Determines wether the given editor input can be serialized by the factory.
|
||||
*/
|
||||
canSerialize(editorInput: IEditorInput): boolean;
|
||||
|
||||
/**
|
||||
* Returns a string representation of the provided editor input that contains enough information
|
||||
* to deserialize back to the original editor input from the deserialize() method.
|
||||
@@ -613,12 +618,12 @@ export const enum EncodingMode {
|
||||
export interface IEncodingSupport {
|
||||
|
||||
/**
|
||||
* Gets the encoding of the input if known.
|
||||
* Gets the encoding of the type if known.
|
||||
*/
|
||||
getEncoding(): string | undefined;
|
||||
|
||||
/**
|
||||
* Sets the encoding for the input for saving.
|
||||
* Sets the encoding for the type for saving.
|
||||
*/
|
||||
setEncoding(encoding: string, mode: EncodingMode): void;
|
||||
}
|
||||
@@ -626,7 +631,7 @@ export interface IEncodingSupport {
|
||||
export interface IModeSupport {
|
||||
|
||||
/**
|
||||
* Sets the language mode of the input.
|
||||
* Sets the language mode of the type.
|
||||
*/
|
||||
setMode(mode: string): void;
|
||||
}
|
||||
@@ -1227,6 +1232,7 @@ export interface IEditorMemento<T> {
|
||||
class EditorInputFactoryRegistry implements IEditorInputFactoryRegistry {
|
||||
private instantiationService: IInstantiationService | undefined;
|
||||
private fileInputFactory: IFileInputFactory | undefined;
|
||||
|
||||
private readonly editorInputFactoryConstructors: Map<string, IConstructorSignature0<IEditorInputFactory>> = new Map();
|
||||
private readonly editorInputFactoryInstances: Map<string, IEditorInputFactory> = new Map();
|
||||
|
||||
@@ -1253,12 +1259,18 @@ class EditorInputFactoryRegistry implements IEditorInputFactoryRegistry {
|
||||
return assertIsDefined(this.fileInputFactory);
|
||||
}
|
||||
|
||||
registerEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>): void {
|
||||
registerEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>): IDisposable {
|
||||
if (!this.instantiationService) {
|
||||
this.editorInputFactoryConstructors.set(editorInputId, ctor);
|
||||
} else {
|
||||
this.createEditorInputFactory(editorInputId, ctor, this.instantiationService);
|
||||
|
||||
}
|
||||
|
||||
return toDisposable(() => {
|
||||
this.editorInputFactoryConstructors.delete(editorInputId);
|
||||
this.editorInputFactoryInstances.delete(editorInputId);
|
||||
});
|
||||
}
|
||||
|
||||
getEditorInputFactory(editorInputId: string): IEditorInputFactory | undefined {
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Extensions, IEditorInputFactoryRegistry, EditorInput, IEditorIdentifier, IEditorCloseEvent, GroupIdentifier, CloseDirection, IEditorInput, SideBySideEditorInput } from 'vs/workbench/common/editor';
|
||||
import { Extensions, IEditorInputFactoryRegistry, EditorInput, IEditorIdentifier, IEditorCloseEvent, GroupIdentifier, CloseDirection, SideBySideEditorInput, IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
|
||||
import { dispose, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { coalesce, firstIndex } from 'vs/base/common/arrays';
|
||||
import { isEqual } from 'vs/base/common/resources';
|
||||
import { IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
@@ -158,18 +160,19 @@ export class EditorGroup extends Disposable {
|
||||
return this.matches(this.preview, editor);
|
||||
}
|
||||
|
||||
openEditor(editor: EditorInput, options?: IEditorOpenOptions): void {
|
||||
const index = this.indexOf(editor);
|
||||
|
||||
openEditor(candidate: EditorInput, options?: IEditorOpenOptions): EditorInput {
|
||||
const makePinned = options?.pinned;
|
||||
const makeActive = options?.active || !this.activeEditor || (!makePinned && this.matches(this.preview, this.activeEditor));
|
||||
|
||||
const existingEditor = this.findEditor(candidate);
|
||||
|
||||
// New editor
|
||||
if (index === -1) {
|
||||
let targetIndex: number;
|
||||
if (!existingEditor) {
|
||||
const newEditor = candidate;
|
||||
const indexOfActive = this.indexOf(this.active);
|
||||
|
||||
// Insert into specific position
|
||||
let targetIndex: number;
|
||||
if (options && typeof options.index === 'number') {
|
||||
targetIndex = options.index;
|
||||
}
|
||||
@@ -200,7 +203,7 @@ export class EditorGroup extends Disposable {
|
||||
|
||||
// Insert into our list of editors if pinned or we have no preview editor
|
||||
if (makePinned || !this.preview) {
|
||||
this.splice(targetIndex, false, editor);
|
||||
this.splice(targetIndex, false, newEditor);
|
||||
}
|
||||
|
||||
// Handle preview
|
||||
@@ -213,22 +216,24 @@ export class EditorGroup extends Disposable {
|
||||
targetIndex--; // accomodate for the fact that the preview editor closes
|
||||
}
|
||||
|
||||
this.replaceEditor(this.preview, editor, targetIndex, !makeActive);
|
||||
this.replaceEditor(this.preview, newEditor, targetIndex, !makeActive);
|
||||
}
|
||||
|
||||
this.preview = editor;
|
||||
this.preview = newEditor;
|
||||
}
|
||||
|
||||
// Listeners
|
||||
this.registerEditorListeners(editor);
|
||||
this.registerEditorListeners(newEditor);
|
||||
|
||||
// Event
|
||||
this._onDidEditorOpen.fire(editor);
|
||||
this._onDidEditorOpen.fire(newEditor);
|
||||
|
||||
// Handle active
|
||||
if (makeActive) {
|
||||
this.setActive(editor);
|
||||
this.doSetActive(newEditor);
|
||||
}
|
||||
|
||||
return newEditor;
|
||||
}
|
||||
|
||||
// Existing editor
|
||||
@@ -236,18 +241,20 @@ export class EditorGroup extends Disposable {
|
||||
|
||||
// Pin it
|
||||
if (makePinned) {
|
||||
this.pin(editor);
|
||||
this.doPin(existingEditor);
|
||||
}
|
||||
|
||||
// Activate it
|
||||
if (makeActive) {
|
||||
this.setActive(editor);
|
||||
this.doSetActive(existingEditor);
|
||||
}
|
||||
|
||||
// Respect index
|
||||
if (options && typeof options.index === 'number') {
|
||||
this.moveEditor(editor, options.index);
|
||||
this.moveEditor(existingEditor, options.index);
|
||||
}
|
||||
|
||||
return existingEditor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,24 +300,26 @@ export class EditorGroup extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
closeEditor(editor: EditorInput, openNext = true): number | undefined {
|
||||
const event = this.doCloseEditor(editor, openNext, false);
|
||||
closeEditor(candidate: EditorInput, openNext = true): EditorInput | undefined {
|
||||
const event = this.doCloseEditor(candidate, openNext, false);
|
||||
|
||||
if (event) {
|
||||
this._onDidEditorClose.fire(event);
|
||||
|
||||
return event.index;
|
||||
return event.editor;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private doCloseEditor(editor: EditorInput, openNext: boolean, replaced: boolean): EditorCloseEvent | null {
|
||||
const index = this.indexOf(editor);
|
||||
private doCloseEditor(candidate: EditorInput, openNext: boolean, replaced: boolean): EditorCloseEvent | undefined {
|
||||
const index = this.indexOf(candidate);
|
||||
if (index === -1) {
|
||||
return null; // not found
|
||||
return undefined; // not found
|
||||
}
|
||||
|
||||
const editor = this.editors[index];
|
||||
|
||||
// Active Editor closed
|
||||
if (openNext && this.matches(this.active, editor)) {
|
||||
|
||||
@@ -327,7 +336,7 @@ export class EditorGroup extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
this.setActive(newActive);
|
||||
this.doSetActive(newActive);
|
||||
}
|
||||
|
||||
// One Editor
|
||||
@@ -383,26 +392,36 @@ export class EditorGroup extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
moveEditor(editor: EditorInput, toIndex: number): void {
|
||||
const index = this.indexOf(editor);
|
||||
moveEditor(candidate: EditorInput, toIndex: number): EditorInput | undefined {
|
||||
const index = this.indexOf(candidate);
|
||||
if (index < 0) {
|
||||
return;
|
||||
return undefined; // {{SQL CARBON EDIT}} strict-null-check
|
||||
}
|
||||
|
||||
const editor = this.editors[index];
|
||||
|
||||
// Move
|
||||
this.editors.splice(index, 1);
|
||||
this.editors.splice(toIndex, 0, editor);
|
||||
|
||||
// Event
|
||||
this._onDidEditorMove.fire(editor);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
setActive(editor: EditorInput): void {
|
||||
const index = this.indexOf(editor);
|
||||
if (index === -1) {
|
||||
return; // not found
|
||||
setActive(candidate: EditorInput): EditorInput | undefined {
|
||||
const editor = this.findEditor(candidate);
|
||||
if (!editor) {
|
||||
return undefined; // not found {{SQL CARBON EDIT}} strict-null-check
|
||||
}
|
||||
|
||||
this.doSetActive(editor);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
private doSetActive(editor: EditorInput): void {
|
||||
if (this.matches(this.active, editor)) {
|
||||
return; // already active
|
||||
}
|
||||
@@ -410,18 +429,26 @@ export class EditorGroup extends Disposable {
|
||||
this.active = editor;
|
||||
|
||||
// Bring to front in MRU list
|
||||
this.setMostRecentlyUsed(editor);
|
||||
const mruIndex = this.indexOf(editor, this.mru);
|
||||
this.mru.splice(mruIndex, 1);
|
||||
this.mru.unshift(editor);
|
||||
|
||||
// Event
|
||||
this._onDidEditorActivate.fire(editor);
|
||||
}
|
||||
|
||||
pin(editor: EditorInput): void {
|
||||
const index = this.indexOf(editor);
|
||||
if (index === -1) {
|
||||
return; // not found
|
||||
pin(candidate: EditorInput): EditorInput | undefined {
|
||||
const editor = this.findEditor(candidate);
|
||||
if (!editor) {
|
||||
return undefined; // not found {{SQL CARBON EDIT}} strict-null-check
|
||||
}
|
||||
|
||||
this.doPin(editor);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
private doPin(editor: EditorInput): void {
|
||||
if (!this.isPreview(editor)) {
|
||||
return; // can only pin a preview editor
|
||||
}
|
||||
@@ -433,12 +460,18 @@ export class EditorGroup extends Disposable {
|
||||
this._onDidEditorPin.fire(editor);
|
||||
}
|
||||
|
||||
unpin(editor: EditorInput): void {
|
||||
const index = this.indexOf(editor);
|
||||
if (index === -1) {
|
||||
return; // not found
|
||||
unpin(candidate: EditorInput): EditorInput | undefined {
|
||||
const editor = this.findEditor(candidate);
|
||||
if (!editor) {
|
||||
return undefined; // not found {{SQL CARBON EDIT}} strict-null-check
|
||||
}
|
||||
|
||||
this.doUnpin(editor);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
private doUnpin(editor: EditorInput): void {
|
||||
if (!this.isPinned(editor)) {
|
||||
return; // can only unpin a pinned editor
|
||||
}
|
||||
@@ -537,7 +570,16 @@ export class EditorGroup extends Disposable {
|
||||
return -1;
|
||||
}
|
||||
|
||||
contains(candidate: EditorInput, searchInSideBySideEditors?: boolean): boolean {
|
||||
private findEditor(candidate: EditorInput | null): EditorInput | undefined {
|
||||
const index = this.indexOf(candidate, this.editors);
|
||||
if (index === -1) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this.editors[index];
|
||||
}
|
||||
|
||||
contains(candidate: EditorInput | IResourceInput, searchInSideBySideEditors?: boolean): boolean {
|
||||
for (const editor of this.editors) {
|
||||
if (this.matches(editor, candidate)) {
|
||||
return true;
|
||||
@@ -553,23 +595,18 @@ export class EditorGroup extends Disposable {
|
||||
return false;
|
||||
}
|
||||
|
||||
private setMostRecentlyUsed(editor: EditorInput): void {
|
||||
const index = this.indexOf(editor);
|
||||
if (index === -1) {
|
||||
return; // editor not found
|
||||
private matches(editor: IEditorInput | null, candidate: IEditorInput | IResourceInput | null): boolean {
|
||||
if (!editor || !candidate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const mruIndex = this.indexOf(editor, this.mru);
|
||||
if (candidate instanceof EditorInput) {
|
||||
return editor.matches(candidate);
|
||||
}
|
||||
|
||||
// Remove old index
|
||||
this.mru.splice(mruIndex, 1);
|
||||
const resource = editor.getResource();
|
||||
|
||||
// Set editor as most recent one (first)
|
||||
this.mru.unshift(editor);
|
||||
}
|
||||
|
||||
private matches(editorA: IEditorInput | null, editorB: IEditorInput | null): boolean {
|
||||
return !!editorA && !!editorB && editorA.matches(editorB);
|
||||
return !!(resource && isEqual(resource, (candidate as IResourceInput).resource));
|
||||
}
|
||||
|
||||
clone(): EditorGroup {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { IBackupFileService, IResolvedBackup } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { ITextBufferFactory } from 'vs/editor/common/model';
|
||||
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
import { IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
@@ -48,7 +48,7 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IEnc
|
||||
@IModeService modeService: IModeService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IBackupFileService private readonly backupFileService: IBackupFileService,
|
||||
@IResourceConfigurationService private readonly configurationService: IResourceConfigurationService,
|
||||
@ITextResourceConfigurationService private readonly configurationService: ITextResourceConfigurationService,
|
||||
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
|
||||
@ITextFileService private readonly textFileService: ITextFileService
|
||||
) {
|
||||
|
||||
@@ -26,6 +26,11 @@ export namespace Extensions {
|
||||
export const ViewsRegistry = 'workbench.registry.view';
|
||||
}
|
||||
|
||||
export enum ViewContainerLocation {
|
||||
Sidebar,
|
||||
Panel
|
||||
}
|
||||
|
||||
export interface IViewContainersRegistry {
|
||||
/**
|
||||
* An event that is triggerred when a view container is registered.
|
||||
@@ -50,7 +55,7 @@ export interface IViewContainersRegistry {
|
||||
*
|
||||
* @returns the registered ViewContainer.
|
||||
*/
|
||||
registerViewContainer(id: string, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier, viewOrderDelegate?: ViewOrderDelegate): ViewContainer;
|
||||
registerViewContainer(id: string, location: ViewContainerLocation, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier, viewOrderDelegate?: ViewOrderDelegate): ViewContainer;
|
||||
|
||||
/**
|
||||
* Deregisters the given view container
|
||||
@@ -71,7 +76,7 @@ interface ViewOrderDelegate {
|
||||
}
|
||||
|
||||
export class ViewContainer {
|
||||
protected constructor(readonly id: string, readonly hideIfEmpty: boolean, readonly extensionId?: ExtensionIdentifier, readonly orderDelegate?: ViewOrderDelegate) { }
|
||||
protected constructor(readonly id: string, readonly location: ViewContainerLocation, readonly hideIfEmpty: boolean, readonly extensionId?: ExtensionIdentifier, readonly orderDelegate?: ViewOrderDelegate) { }
|
||||
}
|
||||
|
||||
class ViewContainersRegistryImpl extends Disposable implements IViewContainersRegistry {
|
||||
@@ -88,7 +93,7 @@ class ViewContainersRegistryImpl extends Disposable implements IViewContainersRe
|
||||
return values(this.viewContainers);
|
||||
}
|
||||
|
||||
registerViewContainer(id: string, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier, viewOrderDelegate?: ViewOrderDelegate): ViewContainer {
|
||||
registerViewContainer(id: string, location: ViewContainerLocation, hideIfEmpty?: boolean, extensionId?: ExtensionIdentifier, viewOrderDelegate?: ViewOrderDelegate): ViewContainer {
|
||||
const existing = this.viewContainers.get(id);
|
||||
if (existing) {
|
||||
return existing;
|
||||
@@ -96,7 +101,7 @@ class ViewContainersRegistryImpl extends Disposable implements IViewContainersRe
|
||||
|
||||
const viewContainer = new class extends ViewContainer {
|
||||
constructor() {
|
||||
super(id, !!hideIfEmpty, extensionId, viewOrderDelegate);
|
||||
super(id, location, !!hideIfEmpty, extensionId, viewOrderDelegate);
|
||||
}
|
||||
};
|
||||
this.viewContainers.set(id, viewContainer);
|
||||
|
||||
Reference in New Issue
Block a user