diff --git a/src/vs/workbench/browser/parts/editor/editorCommands.ts b/src/vs/workbench/browser/parts/editor/editorCommands.ts index 37439353b87e4..5122b21b8d0e0 100644 --- a/src/vs/workbench/browser/parts/editor/editorCommands.ts +++ b/src/vs/workbench/browser/parts/editor/editorCommands.ts @@ -902,11 +902,10 @@ function registerCloseEditorCommands() { for (const { editor, group } of editorsAndGroup) { const untypedEditor = editor.toUntyped(); - - // Resolver can only resolve untyped editors if (!untypedEditor) { - return; + return; // Resolver can only resolve untyped editors } + untypedEditor.options = { ...editorService.activeEditorPane?.options, override: EditorResolution.PICK }; const resolvedEditor = await editorResolverService.resolveEditor(untypedEditor, group); if (!isEditorInputWithOptionsAndGroup(resolvedEditor)) { @@ -925,7 +924,6 @@ function registerCloseEditorCommands() { }); // Telemetry - type WorkbenchEditorReopenClassification = { owner: 'rebornix'; comment: 'Identify how a document is reopened'; @@ -1403,7 +1401,7 @@ export function getEditorsFromContext(accessor: ServicesAccessor, resourceOrCont if (!editor || !group) { return undefined; } - return { editor: editor, group: group }; + return { editor, group }; }); return editorsAndGroup.filter(group => !!group); diff --git a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts index aaa77f5babb00..002d565c6cd18 100644 --- a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts +++ b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts @@ -165,7 +165,7 @@ class DropOverlay extends Themable { isCopy = this.isCopyOperation(e); } else if (isDraggingEditor) { const data = this.editorTransfer.getData(DraggedEditorIdentifier.prototype); - if (Array.isArray(data)) { + if (Array.isArray(data) && data.length > 0) { isCopy = this.isCopyOperation(e, data[0].identifier); } } @@ -234,7 +234,7 @@ class DropOverlay extends Themable { // Check for group transfer if (this.groupTransfer.hasData(DraggedEditorGroupIdentifier.prototype)) { const data = this.groupTransfer.getData(DraggedEditorGroupIdentifier.prototype); - if (Array.isArray(data)) { + if (Array.isArray(data) && data.length > 0) { return this.editorGroupService.getGroup(data[0].identifier); } } @@ -242,7 +242,7 @@ class DropOverlay extends Themable { // Check for editor transfer else if (this.editorTransfer.hasData(DraggedEditorIdentifier.prototype)) { const data = this.editorTransfer.getData(DraggedEditorIdentifier.prototype); - if (Array.isArray(data)) { + if (Array.isArray(data) && data.length > 0) { return this.editorGroupService.getGroup(data[0].identifier.groupId); } } @@ -267,7 +267,7 @@ class DropOverlay extends Themable { // Check for group transfer if (this.groupTransfer.hasData(DraggedEditorGroupIdentifier.prototype)) { const data = this.groupTransfer.getData(DraggedEditorGroupIdentifier.prototype); - if (Array.isArray(data)) { + if (Array.isArray(data) && data.length > 0) { const sourceGroup = this.editorGroupService.getGroup(data[0].identifier); if (sourceGroup) { if (typeof splitDirection !== 'number' && sourceGroup === this.groupView) { @@ -306,7 +306,7 @@ class DropOverlay extends Themable { // Check for editor transfer else if (this.editorTransfer.hasData(DraggedEditorIdentifier.prototype)) { const data = this.editorTransfer.getData(DraggedEditorIdentifier.prototype); - if (Array.isArray(data)) { + if (Array.isArray(data) && data.length > 0) { const draggedEditors = data; const firstDraggedEditor = data[0].identifier; @@ -333,8 +333,8 @@ class DropOverlay extends Themable { { editor: draggedEditor.identifier.editor, options: fillActiveEditorViewState(sourceGroup, draggedEditor.identifier.editor, { - pinned: true, // always pin dropped editor - sticky: sourceGroup.isSticky(firstDraggedEditor.editor), // preserve sticky state + pinned: true, // always pin dropped editor + sticky: sourceGroup.isSticky(firstDraggedEditor.editor) // preserve sticky state }) } )); @@ -357,7 +357,7 @@ class DropOverlay extends Themable { // Check for tree items else if (this.treeItemsTransfer.hasData(DraggedTreeItemsIdentifier.prototype)) { const data = this.treeItemsTransfer.getData(DraggedTreeItemsIdentifier.prototype); - if (Array.isArray(data)) { + if (Array.isArray(data) && data.length > 0) { const editors: IUntypedEditorInput[] = []; for (const id of data) { const dataTransferItem = await this.treeViewsDragAndDropService.removeDragOperationTransfer(id.identifier); diff --git a/src/vs/workbench/browser/parts/editor/editorTabsControl.ts b/src/vs/workbench/browser/parts/editor/editorTabsControl.ts index 5cbcad63de00a..0031e18c565fd 100644 --- a/src/vs/workbench/browser/parts/editor/editorTabsControl.ts +++ b/src/vs/workbench/browser/parts/editor/editorTabsControl.ts @@ -86,7 +86,7 @@ export interface IEditorTabsControl extends IDisposable { stickEditor(editor: EditorInput): void; unstickEditor(editor: EditorInput): void; setActive(isActive: boolean): void; - setEditorSelections(editor: EditorInput[], selected: boolean): void; + setEditorSelections(editors: EditorInput[], selected: boolean): void; updateEditorLabel(editor: EditorInput): void; updateEditorDirty(editor: EditorInput): void; layout(dimensions: IEditorTitleControlDimensions): Dimension; @@ -503,7 +503,7 @@ export abstract class EditorTabsControl extends Themable implements IEditorTabsC abstract setActive(isActive: boolean): void; - abstract setEditorSelections(editor: EditorInput[], selected: boolean): void; + abstract setEditorSelections(editors: EditorInput[], selected: boolean): void; abstract updateEditorLabel(editor: EditorInput): void; diff --git a/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts b/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts index e99641dc2c10a..aa6a35fffcdec 100644 --- a/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts +++ b/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts @@ -1535,7 +1535,7 @@ export class MultiEditorTabsControl extends EditorTabsControl { // Borders / outline this.redrawTabBorders(tabIndex, tabContainer); - // Active / dirty state + // Selection / active / dirty state this.redrawTabSelectedActiveAndDirty(this.groupsView.activeGroup === this.groupView, editor, tabContainer, tabActionBar); } diff --git a/src/vs/workbench/browser/parts/editor/noEditorTabsControl.ts b/src/vs/workbench/browser/parts/editor/noEditorTabsControl.ts index 68eda55c9232e..36a8ac0f0c265 100644 --- a/src/vs/workbench/browser/parts/editor/noEditorTabsControl.ts +++ b/src/vs/workbench/browser/parts/editor/noEditorTabsControl.ts @@ -61,7 +61,7 @@ export class NoEditorTabsControl extends EditorTabsControl { setActive(isActive: boolean): void { } - setEditorSelections(editor: EditorInput[], selected: boolean): void { } + setEditorSelections(editors: EditorInput[], selected: boolean): void { } updateEditorLabel(editor: EditorInput): void { } diff --git a/src/vs/workbench/browser/parts/editor/singleEditorTabsControl.ts b/src/vs/workbench/browser/parts/editor/singleEditorTabsControl.ts index 97f96a7d94879..4b4e48163df0d 100644 --- a/src/vs/workbench/browser/parts/editor/singleEditorTabsControl.ts +++ b/src/vs/workbench/browser/parts/editor/singleEditorTabsControl.ts @@ -179,19 +179,15 @@ export class SingleEditorTabsControl extends EditorTabsControl { this.ifEditorIsActive(editor, () => this.redraw()); } - stickEditor(editor: EditorInput): void { - // Sticky editors are not presented any different with tabs disabled - } + stickEditor(editor: EditorInput): void { } - unstickEditor(editor: EditorInput): void { - // Sticky editors are not presented any different with tabs disabled - } + unstickEditor(editor: EditorInput): void { } setActive(isActive: boolean): void { this.redraw(); } - setEditorSelections(editor: EditorInput[], selected: boolean): void { } + setEditorSelections(editors: EditorInput[], selected: boolean): void { } updateEditorLabel(editor: EditorInput): void { this.ifEditorIsActive(editor, () => this.redraw()); diff --git a/src/vs/workbench/common/editor/editorGroupModel.ts b/src/vs/workbench/common/editor/editorGroupModel.ts index ab75d18ab3fa5..515f3408e1031 100644 --- a/src/vs/workbench/common/editor/editorGroupModel.ts +++ b/src/vs/workbench/common/editor/editorGroupModel.ts @@ -221,17 +221,18 @@ export class EditorGroupModel extends Disposable implements IEditorGroupModel { private locked = false; - private selected: EditorInput[] = []; // editors in selected state, first one is active + private selected: EditorInput[] = []; // editors in selected state, first one is active + private set active(editor: EditorInput | null) { this.selected = editor ? [editor] : []; } private get active(): EditorInput | null { - return this.selected[0] || null; + return this.selected[0] ?? null; } - private preview: EditorInput | null = null; // editor in preview state - private sticky = -1; // index of first editor in sticky state - private readonly transient = new Set(); // editors in transient state + private preview: EditorInput | null = null; // editor in preview state + private sticky = -1; // index of first editor in sticky state + private readonly transient = new Set(); // editors in transient state private editorOpenPositioning: ('left' | 'right' | 'first' | 'last') | undefined; private focusRecentEditorAfterClose: boolean | undefined; @@ -582,6 +583,7 @@ export class EditorGroupModel extends Disposable implements IEditorGroupModel { this.active = null; } } + // Remove from selection else if (!isActiveEditor) { const wasSelected = !!this.selected.find(selected => this.matches(selected, editor)); @@ -729,7 +731,7 @@ export class EditorGroupModel extends Disposable implements IEditorGroupModel { return this.editors.filter(editor => this.isSelected(editor)); } - isSelected(editor: number | EditorInput): boolean { + isSelected(editor: EditorInput | number): boolean { if (typeof editor === 'number') { editor = this.editors[editor]; } diff --git a/src/vs/workbench/common/editor/filteredEditorGroupModel.ts b/src/vs/workbench/common/editor/filteredEditorGroupModel.ts index 787ee09f00124..fcda0bbed00a1 100644 --- a/src/vs/workbench/common/editor/filteredEditorGroupModel.ts +++ b/src/vs/workbench/common/editor/filteredEditorGroupModel.ts @@ -42,7 +42,7 @@ abstract class FilteredEditorGroupModel extends Disposable implements IReadonlyE isTransient(editorOrIndex: EditorInput | number): boolean { return this.model.isTransient(editorOrIndex); } isSticky(editorOrIndex: EditorInput | number): boolean { return this.model.isSticky(editorOrIndex); } isActive(editor: EditorInput | IUntypedEditorInput): boolean { return this.model.isActive(editor); } - isSelected(editor: number | EditorInput): boolean { return this.model.isSelected(editor); } + isSelected(editor: EditorInput | number): boolean { return this.model.isSelected(editor); } isFirst(editor: EditorInput): boolean { return this.model.isFirst(editor, this.getEditors(EditorsOrder.SEQUENTIAL)); diff --git a/src/vs/workbench/services/editor/common/editorGroupsService.ts b/src/vs/workbench/services/editor/common/editorGroupsService.ts index cb9c84b7590b4..6ecc2b3d33350 100644 --- a/src/vs/workbench/services/editor/common/editorGroupsService.ts +++ b/src/vs/workbench/services/editor/common/editorGroupsService.ts @@ -779,7 +779,6 @@ export interface IEditorGroup { */ selectEditor(editor: EditorInput, active?: boolean): Promise; - /** * Selects the editors in the group. If activeEditor is provided, * it will be the active editor in the group.