|
5 | 5 |
|
6 | 6 | import { localize } from 'vs/nls'; |
7 | 7 | import { IQuickPickSeparator, quickPickItemScorerAccessor, IQuickPickItemWithResource } from 'vs/platform/quickinput/common/quickInput'; |
8 | | -import { PickerQuickAccessProvider, IPickerQuickAccessItem } from 'vs/platform/quickinput/common/quickAccess'; |
| 8 | +import { PickerQuickAccessProvider, IPickerQuickAccessItem, TriggerAction } from 'vs/platform/quickinput/common/quickAccess'; |
9 | 9 | import { IEditorGroupsService, GroupsOrder } from 'vs/workbench/services/editor/common/editorGroupsService'; |
10 | 10 | import { EditorsOrder, IEditorIdentifier, toResource, SideBySideEditor } from 'vs/workbench/common/editor'; |
11 | 11 | import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; |
@@ -83,19 +83,32 @@ export abstract class BaseEditorQuickAccessProvider extends PickerQuickAccessPro |
83 | 83 | } |
84 | 84 |
|
85 | 85 | private doGetEditorPickItems(): Array<IEditorQuickPickItem> { |
86 | | - return this.doGetEditors().map(({ editor, groupId }) => { |
| 86 | + return this.doGetEditors().map(({ editor, groupId }): IEditorQuickPickItem => { |
87 | 87 | const resource = toResource(editor, { supportSideBySide: SideBySideEditor.MASTER }); |
| 88 | + const isDirty = editor.isDirty() && !editor.isSaving(); |
88 | 89 |
|
89 | 90 | return { |
90 | 91 | editor, |
91 | 92 | groupId, |
92 | 93 | resource, |
93 | | - label: editor.isDirty() && !editor.isSaving() ? `$(circle-filled) ${editor.getName()}` : editor.getName(), |
94 | | - ariaLabel: localize('entryAriaLabel', "{0}, editor picker", editor.getName()), |
| 94 | + label: editor.getName(), |
| 95 | + ariaLabel: localize('entryAriaLabel', "{0}, editors picker", editor.getName()), |
95 | 96 | description: editor.getDescription(), |
96 | 97 | iconClasses: getIconClasses(this.modelService, this.modeService, resource), |
97 | 98 | italic: !this.editorGroupService.getGroup(groupId)?.isPinned(editor), |
98 | | - accept: () => this.editorGroupService.getGroup(groupId)?.openEditor(editor) |
| 99 | + buttonsAlwaysVisible: isDirty, |
| 100 | + buttons: [ |
| 101 | + { |
| 102 | + iconClass: isDirty ? 'codicon-circle-filled' : 'codicon-close', |
| 103 | + tooltip: localize('closeEditor', "Close Editor") |
| 104 | + } |
| 105 | + ], |
| 106 | + trigger: async () => { |
| 107 | + await this.editorGroupService.getGroup(groupId)?.closeEditor(editor, { preserveFocus: true }); |
| 108 | + |
| 109 | + return TriggerAction.REFRESH_PICKER; |
| 110 | + }, |
| 111 | + accept: () => this.editorGroupService.getGroup(groupId)?.openEditor(editor), |
99 | 112 | }; |
100 | 113 | }); |
101 | 114 | } |
|
0 commit comments