@codingame/monaco-vscode-views-service-override 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +11 -11
- package/tools/editor.js +14 -0
- package/views.js +12 -5
- package/vscode/src/vs/base/common/codicons.d.ts +5 -0
- package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +2 -2
- package/vscode/src/vs/workbench/browser/actions/listCommands.js +160 -4
- package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +14 -19
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +59 -21
- package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +77 -45
- package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +23 -1
- package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +77 -45
- package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +131 -5
- package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +2 -2
- package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.d.ts +1 -3
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +8 -16
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +13 -13
- package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditor.js +8 -3
- package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.js +1 -1
- package/vscode/src/vs/workbench/contrib/files/browser/explorerService.js +4 -0
- package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +3 -4
- package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +1 -1
- package/vscode/src/vs/workbench/contrib/files/browser/workspaceWatcher.js +1 -1
- package/vscode/src/vs/workbench/contrib/files/common/dirtyFilesIndicator.js +1 -1
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +17 -16
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +4 -4
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +1 -1
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +13 -13
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +2 -2
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +1 -1
- package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +2 -1
- package/vscode/src/vs/workbench/services/activity/browser/activityService.js +1 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +18 -4
- package/vscode/src/vs/workbench/services/history/browser/historyService.js +2 -2
- package/vscode/src/vs/workbench/services/progress/browser/progressService.js +15 -4
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +2 -2
- package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +6 -2
- package/vscode/src/vs/base/browser/ui/breadcrumbs/breadcrumbsWidget.css.js +0 -6
- package/vscode/src/vs/base/browser/ui/breadcrumbs/breadcrumbsWidget.js +0 -290
- package/vscode/src/vs/workbench/browser/parts/editor/breadcrumbsControl.js +0 -801
- package/vscode/src/vs/workbench/browser/parts/editor/breadcrumbsModel.js +0 -142
- package/vscode/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.js +0 -412
- package/vscode/src/vs/workbench/browser/parts/editor/editorGroupView.js +0 -1315
- package/vscode/src/vs/workbench/browser/parts/editor/editorGroupWatermark.js +0 -186
- package/vscode/src/vs/workbench/browser/parts/editor/editorPanes.js +0 -346
- package/vscode/src/vs/workbench/browser/parts/editor/editorTitleControl.js +0 -154
- package/vscode/src/vs/workbench/browser/parts/editor/media/breadcrumbscontrol.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/editor/media/editorgroupview.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/editor/media/editortitlecontrol.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/editor/media/multieditortabscontrol.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/editor/media/singleeditortabscontrol.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.js +0 -1623
- package/vscode/src/vs/workbench/browser/parts/editor/multiRowEditorTabsControl.js +0 -152
- package/vscode/src/vs/workbench/browser/parts/editor/noEditorTabsControl.js +0 -54
- package/vscode/src/vs/workbench/browser/parts/editor/singleEditorTabsControl.js +0 -259
- package/vscode/src/vs/workbench/common/editor/filteredEditorGroupModel.js +0 -109
- package/vscode/src/vs/workbench/services/hover/browser/hoverService.js +0 -195
- package/vscode/src/vs/workbench/services/hover/browser/hoverWidget.js +0 -528
- package/vscode/src/vs/workbench/services/hover/browser/media/hover.css.js +0 -6
|
@@ -1,1315 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import './media/editorgroupview.css.js';
|
|
3
|
-
import { isSerializedEditorGroupModel, EditorGroupModel, isGroupEditorCloseEvent, isGroupEditorOpenEvent } from 'vscode/vscode/vs/workbench/common/editor/editorGroupModel';
|
|
4
|
-
import { DEFAULT_EDITOR_ASSOCIATION, SideBySideEditor, EditorResourceAccessor, EditorCloseContext } from 'vscode/vscode/vs/workbench/common/editor';
|
|
5
|
-
import { ResourceContextKey, ActiveEditorDirtyContext, ActiveEditorPinnedContext, ActiveEditorFirstInGroupContext, ActiveEditorLastInGroupContext, ActiveEditorStickyContext, EditorGroupEditorsCountContext, ActiveEditorGroupLockedContext, EditorPinnedAndUnpinnedTabsContext, ActiveEditorAvailableEditorIdsContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, applyAvailableEditorIds } from 'vscode/vscode/vs/workbench/common/contextkeys';
|
|
6
|
-
import { SideBySideEditorInput } from 'vscode/vscode/vs/workbench/common/editor/sideBySideEditorInput';
|
|
7
|
-
import { Emitter, Relay } from 'vscode/vscode/vs/base/common/event';
|
|
8
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
9
|
-
import { addDisposableListener, EventType, EventHelper, getWindow, trackFocus, isActiveElement, focusWindow, isAncestor, Dimension, isMouseEvent, findParentWithClass } from 'vscode/vscode/vs/base/browser/dom';
|
|
10
|
-
import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
|
|
11
|
-
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
12
|
-
import { ProgressBar } from 'vscode/vscode/vs/base/browser/ui/progressbar/progressbar';
|
|
13
|
-
import { Themable, IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
14
|
-
import { contrastBorder, editorBackground } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
|
|
15
|
-
import { EDITOR_GROUP_EMPTY_BACKGROUND, EDITOR_GROUP_HEADER_BORDER, EDITOR_GROUP_HEADER_TABS_BACKGROUND, EDITOR_GROUP_HEADER_NO_TABS_BACKGROUND } from 'vscode/vscode/vs/workbench/common/theme';
|
|
16
|
-
import { EditorPanes } from './editorPanes.js';
|
|
17
|
-
import { IEditorProgressService } from 'vscode/vscode/vs/platform/progress/common/progress';
|
|
18
|
-
import { EditorProgressIndicator } from 'vscode/vscode/vs/workbench/services/progress/browser/progressIndicator';
|
|
19
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
20
|
-
import { coalesce, firstOrDefault } from 'vscode/vscode/vs/base/common/arrays';
|
|
21
|
-
import { MutableDisposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
22
|
-
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
23
|
-
import { RunOnceWorker, DeferredPromise, Promises } from 'vscode/vscode/vs/base/common/async';
|
|
24
|
-
import { EventType as EventType$1 } from 'vscode/vscode/vs/base/browser/touch';
|
|
25
|
-
import { fillActiveEditorViewState } from 'vscode/vscode/vs/workbench/browser/parts/editor/editor';
|
|
26
|
-
import { ActionBar } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionbar';
|
|
27
|
-
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
28
|
-
import { MenuId, IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
29
|
-
import { StandardMouseEvent } from 'vscode/vscode/vs/base/browser/mouseEvent';
|
|
30
|
-
import { createAndFillInActionBarActions } from 'vscode/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
|
|
31
|
-
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
32
|
-
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
33
|
-
import { hash } from 'vscode/vscode/vs/base/common/hash';
|
|
34
|
-
import { getMimeTypes } from 'vscode/vscode/vs/editor/common/services/languagesAssociations';
|
|
35
|
-
import { extname, isEqual } from 'vscode/vscode/vs/base/common/resources';
|
|
36
|
-
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
37
|
-
import { EditorActivation } from 'vscode/vscode/vs/platform/editor/common/editor';
|
|
38
|
-
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
39
|
-
import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
|
40
|
-
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
41
|
-
import { isNative, isWindows, isLinux, isMacintosh } from 'vscode/vscode/vs/base/common/platform';
|
|
42
|
-
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
43
|
-
import { TelemetryTrustedValue } from 'vscode/vscode/vs/platform/telemetry/common/telemetryUtils';
|
|
44
|
-
import { defaultProgressBarStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
|
|
45
|
-
import { EditorGroupWatermark } from './editorGroupWatermark.js';
|
|
46
|
-
import { EditorTitleControl } from './editorTitleControl.js';
|
|
47
|
-
import { EditorPane } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorPane';
|
|
48
|
-
import { IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
|
|
49
|
-
import { IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
50
|
-
|
|
51
|
-
var EditorGroupView_1;
|
|
52
|
-
let EditorGroupView = EditorGroupView_1 = class EditorGroupView extends Themable {
|
|
53
|
-
static createNew(editorPartsView, groupsView, groupsLabel, groupIndex, instantiationService) {
|
|
54
|
-
return instantiationService.createInstance(EditorGroupView_1, null, editorPartsView, groupsView, groupsLabel, groupIndex);
|
|
55
|
-
}
|
|
56
|
-
static createFromSerialized(serialized, editorPartsView, groupsView, groupsLabel, groupIndex, instantiationService) {
|
|
57
|
-
return instantiationService.createInstance(EditorGroupView_1, serialized, editorPartsView, groupsView, groupsLabel, groupIndex);
|
|
58
|
-
}
|
|
59
|
-
static createCopy(copyFrom, editorPartsView, groupsView, groupsLabel, groupIndex, instantiationService) {
|
|
60
|
-
return instantiationService.createInstance(EditorGroupView_1, copyFrom, editorPartsView, groupsView, groupsLabel, groupIndex);
|
|
61
|
-
}
|
|
62
|
-
constructor(from, editorPartsView, groupsView, groupsLabel, _index, instantiationService, contextKeyService, themeService, telemetryService, keybindingService, menuService, contextMenuService, fileDialogService, editorService, filesConfigurationService, uriIdentityService, logService, editorResolverService) {
|
|
63
|
-
super(themeService);
|
|
64
|
-
this.editorPartsView = editorPartsView;
|
|
65
|
-
this.groupsView = groupsView;
|
|
66
|
-
this.groupsLabel = groupsLabel;
|
|
67
|
-
this._index = _index;
|
|
68
|
-
this.instantiationService = instantiationService;
|
|
69
|
-
this.contextKeyService = contextKeyService;
|
|
70
|
-
this.telemetryService = telemetryService;
|
|
71
|
-
this.keybindingService = keybindingService;
|
|
72
|
-
this.menuService = menuService;
|
|
73
|
-
this.contextMenuService = contextMenuService;
|
|
74
|
-
this.fileDialogService = fileDialogService;
|
|
75
|
-
this.editorService = editorService;
|
|
76
|
-
this.filesConfigurationService = filesConfigurationService;
|
|
77
|
-
this.uriIdentityService = uriIdentityService;
|
|
78
|
-
this.logService = logService;
|
|
79
|
-
this.editorResolverService = editorResolverService;
|
|
80
|
-
this._onDidFocus = this._register(( new Emitter()));
|
|
81
|
-
this.onDidFocus = this._onDidFocus.event;
|
|
82
|
-
this._onWillDispose = this._register(( new Emitter()));
|
|
83
|
-
this.onWillDispose = this._onWillDispose.event;
|
|
84
|
-
this._onDidModelChange = this._register(( new Emitter()));
|
|
85
|
-
this.onDidModelChange = this._onDidModelChange.event;
|
|
86
|
-
this._onDidActiveEditorChange = this._register(( new Emitter()));
|
|
87
|
-
this.onDidActiveEditorChange = this._onDidActiveEditorChange.event;
|
|
88
|
-
this._onDidOpenEditorFail = this._register(( new Emitter()));
|
|
89
|
-
this.onDidOpenEditorFail = this._onDidOpenEditorFail.event;
|
|
90
|
-
this._onWillCloseEditor = this._register(( new Emitter()));
|
|
91
|
-
this.onWillCloseEditor = this._onWillCloseEditor.event;
|
|
92
|
-
this._onDidCloseEditor = this._register(( new Emitter()));
|
|
93
|
-
this.onDidCloseEditor = this._onDidCloseEditor.event;
|
|
94
|
-
this._onWillMoveEditor = this._register(( new Emitter()));
|
|
95
|
-
this.onWillMoveEditor = this._onWillMoveEditor.event;
|
|
96
|
-
this._onWillOpenEditor = this._register(( new Emitter()));
|
|
97
|
-
this.onWillOpenEditor = this._onWillOpenEditor.event;
|
|
98
|
-
this.disposedEditorsWorker = this._register(( new RunOnceWorker(editors => this.handleDisposedEditors(editors), 0)));
|
|
99
|
-
this.mapEditorToPendingConfirmation = ( new Map());
|
|
100
|
-
this.containerToolBarMenuDisposable = this._register(( new MutableDisposable()));
|
|
101
|
-
this.whenRestoredPromise = ( new DeferredPromise());
|
|
102
|
-
this.whenRestored = this.whenRestoredPromise.p;
|
|
103
|
-
this._disposed = false;
|
|
104
|
-
this.element = document.createElement('div');
|
|
105
|
-
this._onDidChange = this._register(( new Relay()));
|
|
106
|
-
this.onDidChange = this._onDidChange.event;
|
|
107
|
-
if (from instanceof EditorGroupView_1) {
|
|
108
|
-
this.model = this._register(from.model.clone());
|
|
109
|
-
}
|
|
110
|
-
else if (isSerializedEditorGroupModel(from)) {
|
|
111
|
-
this.model = this._register(instantiationService.createInstance(EditorGroupModel, from));
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
this.model = this._register(instantiationService.createInstance(EditorGroupModel, undefined));
|
|
115
|
-
}
|
|
116
|
-
{
|
|
117
|
-
this.scopedContextKeyService = this._register(this.contextKeyService.createScoped(this.element));
|
|
118
|
-
this.element.classList.add('editor-group-container');
|
|
119
|
-
this.registerContainerListeners();
|
|
120
|
-
this.createContainerToolbar();
|
|
121
|
-
this.createContainerContextMenu();
|
|
122
|
-
this._register(this.instantiationService.createInstance(EditorGroupWatermark, this.element));
|
|
123
|
-
this.progressBar = this._register(( new ProgressBar(this.element, defaultProgressBarStyles)));
|
|
124
|
-
this.progressBar.hide();
|
|
125
|
-
this.scopedInstantiationService = this.instantiationService.createChild(( new ServiceCollection(
|
|
126
|
-
[IContextKeyService, this.scopedContextKeyService],
|
|
127
|
-
[IEditorProgressService, this._register(( new EditorProgressIndicator(this.progressBar, this)))]
|
|
128
|
-
)));
|
|
129
|
-
this.resourceContext = this._register(this.scopedInstantiationService.createInstance(ResourceContextKey));
|
|
130
|
-
this.handleGroupContextKeys();
|
|
131
|
-
this.titleContainer = document.createElement('div');
|
|
132
|
-
this.titleContainer.classList.add('title');
|
|
133
|
-
this.element.appendChild(this.titleContainer);
|
|
134
|
-
this.titleControl = this._register(this.scopedInstantiationService.createInstance(EditorTitleControl, this.titleContainer, this.editorPartsView, this.groupsView, this, this.model));
|
|
135
|
-
this.editorContainer = document.createElement('div');
|
|
136
|
-
this.editorContainer.classList.add('editor-container');
|
|
137
|
-
this.element.appendChild(this.editorContainer);
|
|
138
|
-
this.editorPane = this._register(this.scopedInstantiationService.createInstance(EditorPanes, this.element, this.editorContainer, this));
|
|
139
|
-
this._onDidChange.input = this.editorPane.onDidChangeSizeConstraints;
|
|
140
|
-
this.doTrackFocus();
|
|
141
|
-
this.updateTitleContainer();
|
|
142
|
-
this.updateContainer();
|
|
143
|
-
this.updateStyles();
|
|
144
|
-
}
|
|
145
|
-
const restoreEditorsPromise = this.restoreEditors(from) ?? Promise.resolve();
|
|
146
|
-
restoreEditorsPromise.finally(() => {
|
|
147
|
-
this.whenRestoredPromise.complete();
|
|
148
|
-
});
|
|
149
|
-
this.registerListeners();
|
|
150
|
-
}
|
|
151
|
-
handleGroupContextKeys() {
|
|
152
|
-
const groupActiveEditorDirtyContext = ActiveEditorDirtyContext.bindTo(this.scopedContextKeyService);
|
|
153
|
-
const groupActiveEditorPinnedContext = ActiveEditorPinnedContext.bindTo(this.scopedContextKeyService);
|
|
154
|
-
const groupActiveEditorFirstContext = ActiveEditorFirstInGroupContext.bindTo(this.scopedContextKeyService);
|
|
155
|
-
const groupActiveEditorLastContext = ActiveEditorLastInGroupContext.bindTo(this.scopedContextKeyService);
|
|
156
|
-
const groupActiveEditorStickyContext = ActiveEditorStickyContext.bindTo(this.scopedContextKeyService);
|
|
157
|
-
const groupEditorsCountContext = EditorGroupEditorsCountContext.bindTo(this.scopedContextKeyService);
|
|
158
|
-
const groupLockedContext = ActiveEditorGroupLockedContext.bindTo(this.scopedContextKeyService);
|
|
159
|
-
const groupHasPinnedAndUnpinnedContext = EditorPinnedAndUnpinnedTabsContext.bindTo(this.scopedContextKeyService);
|
|
160
|
-
const groupActiveEditorAvailableEditorIds = ActiveEditorAvailableEditorIdsContext.bindTo(this.scopedContextKeyService);
|
|
161
|
-
const groupActiveEditorCanSplitInGroupContext = ActiveEditorCanSplitInGroupContext.bindTo(this.scopedContextKeyService);
|
|
162
|
-
const sideBySideEditorContext = SideBySideEditorActiveContext.bindTo(this.scopedContextKeyService);
|
|
163
|
-
const activeEditorListener = this._register(( new MutableDisposable()));
|
|
164
|
-
const observeActiveEditor = () => {
|
|
165
|
-
activeEditorListener.clear();
|
|
166
|
-
this.scopedContextKeyService.bufferChangeEvents(() => {
|
|
167
|
-
const activeEditor = this.activeEditor;
|
|
168
|
-
this.resourceContext.set(EditorResourceAccessor.getOriginalUri(activeEditor, { supportSideBySide: SideBySideEditor.PRIMARY } ?? null));
|
|
169
|
-
applyAvailableEditorIds(groupActiveEditorAvailableEditorIds, activeEditor, this.editorResolverService);
|
|
170
|
-
groupActiveEditorCanSplitInGroupContext.set(activeEditor ? activeEditor.hasCapability(32 ) : false);
|
|
171
|
-
sideBySideEditorContext.set(activeEditor?.typeId === SideBySideEditorInput.ID);
|
|
172
|
-
if (activeEditor) {
|
|
173
|
-
groupActiveEditorDirtyContext.set(activeEditor.isDirty() && !activeEditor.isSaving());
|
|
174
|
-
activeEditorListener.value = activeEditor.onDidChangeDirty(() => {
|
|
175
|
-
groupActiveEditorDirtyContext.set(activeEditor.isDirty() && !activeEditor.isSaving());
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
groupActiveEditorDirtyContext.set(false);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
this._register(this.onDidModelChange(e => {
|
|
184
|
-
switch (e.kind) {
|
|
185
|
-
case 3 :
|
|
186
|
-
groupLockedContext.set(this.isLocked);
|
|
187
|
-
break;
|
|
188
|
-
case 5 :
|
|
189
|
-
case 4 :
|
|
190
|
-
groupHasPinnedAndUnpinnedContext.set(this.hasPinnedAndUnpinnedEditors());
|
|
191
|
-
case 7 :
|
|
192
|
-
case 6 :
|
|
193
|
-
groupActiveEditorFirstContext.set(this.model.isFirst(this.model.activeEditor));
|
|
194
|
-
groupActiveEditorLastContext.set(this.model.isLast(this.model.activeEditor));
|
|
195
|
-
break;
|
|
196
|
-
case 10 :
|
|
197
|
-
if (e.editor && e.editor === this.model.activeEditor) {
|
|
198
|
-
groupActiveEditorPinnedContext.set(this.model.isPinned(this.model.activeEditor));
|
|
199
|
-
}
|
|
200
|
-
break;
|
|
201
|
-
case 11 :
|
|
202
|
-
if (e.editor && e.editor === this.model.activeEditor) {
|
|
203
|
-
groupActiveEditorStickyContext.set(this.model.isSticky(this.model.activeEditor));
|
|
204
|
-
}
|
|
205
|
-
groupHasPinnedAndUnpinnedContext.set(this.hasPinnedAndUnpinnedEditors());
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
groupEditorsCountContext.set(this.count);
|
|
209
|
-
}));
|
|
210
|
-
this._register(this.onDidActiveEditorChange(() => {
|
|
211
|
-
observeActiveEditor();
|
|
212
|
-
}));
|
|
213
|
-
observeActiveEditor();
|
|
214
|
-
groupHasPinnedAndUnpinnedContext.set(this.hasPinnedAndUnpinnedEditors());
|
|
215
|
-
}
|
|
216
|
-
hasPinnedAndUnpinnedEditors() {
|
|
217
|
-
return this.model.stickyCount > 0 && this.model.stickyCount < this.model.count;
|
|
218
|
-
}
|
|
219
|
-
registerContainerListeners() {
|
|
220
|
-
this._register(addDisposableListener(this.element, EventType.DBLCLICK, e => {
|
|
221
|
-
if (this.isEmpty) {
|
|
222
|
-
EventHelper.stop(e);
|
|
223
|
-
this.editorService.openEditor({
|
|
224
|
-
resource: undefined,
|
|
225
|
-
options: {
|
|
226
|
-
pinned: true,
|
|
227
|
-
override: DEFAULT_EDITOR_ASSOCIATION.id
|
|
228
|
-
}
|
|
229
|
-
}, this.id);
|
|
230
|
-
}
|
|
231
|
-
}));
|
|
232
|
-
this._register(addDisposableListener(this.element, EventType.AUXCLICK, e => {
|
|
233
|
-
if (this.isEmpty && e.button === 1 ) {
|
|
234
|
-
EventHelper.stop(e, true);
|
|
235
|
-
this.groupsView.removeGroup(this);
|
|
236
|
-
}
|
|
237
|
-
}));
|
|
238
|
-
}
|
|
239
|
-
createContainerToolbar() {
|
|
240
|
-
const toolbarContainer = document.createElement('div');
|
|
241
|
-
toolbarContainer.classList.add('editor-group-container-toolbar');
|
|
242
|
-
this.element.appendChild(toolbarContainer);
|
|
243
|
-
const containerToolbar = this._register(( new ActionBar(toolbarContainer, {
|
|
244
|
-
ariaLabel: ( localizeWithPath(
|
|
245
|
-
'vs/workbench/browser/parts/editor/editorGroupView',
|
|
246
|
-
'ariaLabelGroupActions',
|
|
247
|
-
"Empty editor group actions"
|
|
248
|
-
)),
|
|
249
|
-
highlightToggledItems: true
|
|
250
|
-
})));
|
|
251
|
-
const containerToolbarMenu = this._register(this.menuService.createMenu(MenuId.EmptyEditorGroup, this.scopedContextKeyService));
|
|
252
|
-
const updateContainerToolbar = () => {
|
|
253
|
-
const actions = { primary: [], secondary: [] };
|
|
254
|
-
this.containerToolBarMenuDisposable.value = toDisposable(() => containerToolbar.clear());
|
|
255
|
-
createAndFillInActionBarActions(containerToolbarMenu, { arg: { groupId: this.id }, shouldForwardArgs: true }, actions, 'navigation');
|
|
256
|
-
for (const action of [...actions.primary, ...actions.secondary]) {
|
|
257
|
-
const keybinding = this.keybindingService.lookupKeybinding(action.id);
|
|
258
|
-
containerToolbar.push(action, { icon: true, label: false, keybinding: keybinding?.getLabel() });
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
updateContainerToolbar();
|
|
262
|
-
this._register(containerToolbarMenu.onDidChange(updateContainerToolbar));
|
|
263
|
-
}
|
|
264
|
-
createContainerContextMenu() {
|
|
265
|
-
this._register(addDisposableListener(this.element, EventType.CONTEXT_MENU, e => this.onShowContainerContextMenu(e)));
|
|
266
|
-
this._register(addDisposableListener(this.element, EventType$1.Contextmenu, () => this.onShowContainerContextMenu()));
|
|
267
|
-
}
|
|
268
|
-
onShowContainerContextMenu(e) {
|
|
269
|
-
if (!this.isEmpty) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
let anchor = this.element;
|
|
273
|
-
if (e) {
|
|
274
|
-
anchor = ( new StandardMouseEvent(getWindow(this.element), e));
|
|
275
|
-
}
|
|
276
|
-
this.contextMenuService.showContextMenu({
|
|
277
|
-
menuId: MenuId.EmptyEditorGroupContext,
|
|
278
|
-
contextKeyService: this.contextKeyService,
|
|
279
|
-
getAnchor: () => anchor,
|
|
280
|
-
onHide: () => {
|
|
281
|
-
this.focus();
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
doTrackFocus() {
|
|
286
|
-
const containerFocusTracker = this._register(trackFocus(this.element));
|
|
287
|
-
this._register(containerFocusTracker.onDidFocus(() => {
|
|
288
|
-
if (this.isEmpty) {
|
|
289
|
-
this._onDidFocus.fire();
|
|
290
|
-
}
|
|
291
|
-
}));
|
|
292
|
-
const handleTitleClickOrTouch = (e) => {
|
|
293
|
-
let target;
|
|
294
|
-
if (isMouseEvent(e)) {
|
|
295
|
-
if (e.button !== 0 || ((isMacintosh && e.ctrlKey) )) {
|
|
296
|
-
return undefined;
|
|
297
|
-
}
|
|
298
|
-
target = e.target;
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
target = e.initialTarget;
|
|
302
|
-
}
|
|
303
|
-
if (findParentWithClass(target, 'monaco-action-bar', this.titleContainer) ||
|
|
304
|
-
findParentWithClass(target, 'monaco-breadcrumb-item', this.titleContainer)) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
setTimeout(() => {
|
|
308
|
-
this.focus();
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
this._register(addDisposableListener(this.titleContainer, EventType.MOUSE_DOWN, e => handleTitleClickOrTouch(e)));
|
|
312
|
-
this._register(addDisposableListener(this.titleContainer, EventType$1.Tap, e => handleTitleClickOrTouch(e)));
|
|
313
|
-
this._register(this.editorPane.onDidFocus(() => {
|
|
314
|
-
this._onDidFocus.fire();
|
|
315
|
-
}));
|
|
316
|
-
}
|
|
317
|
-
updateContainer() {
|
|
318
|
-
if (this.isEmpty) {
|
|
319
|
-
this.element.classList.add('empty');
|
|
320
|
-
this.element.tabIndex = 0;
|
|
321
|
-
this.element.setAttribute('aria-label', ( localizeWithPath(
|
|
322
|
-
'vs/workbench/browser/parts/editor/editorGroupView',
|
|
323
|
-
'emptyEditorGroup',
|
|
324
|
-
"{0} (empty)",
|
|
325
|
-
this.ariaLabel
|
|
326
|
-
)));
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
this.element.classList.remove('empty');
|
|
330
|
-
this.element.removeAttribute('tabIndex');
|
|
331
|
-
this.element.removeAttribute('aria-label');
|
|
332
|
-
}
|
|
333
|
-
this.updateStyles();
|
|
334
|
-
}
|
|
335
|
-
updateTitleContainer() {
|
|
336
|
-
this.titleContainer.classList.toggle('tabs', this.groupsView.partOptions.showTabs === 'multiple');
|
|
337
|
-
this.titleContainer.classList.toggle('show-file-icons', this.groupsView.partOptions.showIcons);
|
|
338
|
-
}
|
|
339
|
-
restoreEditors(from) {
|
|
340
|
-
if (this.count === 0) {
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
let options;
|
|
344
|
-
if (from instanceof EditorGroupView_1) {
|
|
345
|
-
options = fillActiveEditorViewState(from);
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
options = Object.create(null);
|
|
349
|
-
}
|
|
350
|
-
const activeEditor = this.model.activeEditor;
|
|
351
|
-
if (!activeEditor) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
options.pinned = this.model.isPinned(activeEditor);
|
|
355
|
-
options.sticky = this.model.isSticky(activeEditor);
|
|
356
|
-
options.preserveFocus = true;
|
|
357
|
-
const activeElement = this.editorContainer.ownerDocument.activeElement;
|
|
358
|
-
return this.doShowEditor(activeEditor, { active: true, isNew: false }, options).then(() => {
|
|
359
|
-
if (this.groupsView.activeGroup === this && activeElement && isActiveElement(activeElement)) {
|
|
360
|
-
this.focus();
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
registerListeners() {
|
|
365
|
-
this._register(this.model.onDidModelChange(e => this.onDidGroupModelChange(e)));
|
|
366
|
-
this._register(this.groupsView.onDidChangeEditorPartOptions(e => this.onDidChangeEditorPartOptions(e)));
|
|
367
|
-
this._register(this.groupsView.onDidVisibilityChange(e => this.onDidVisibilityChange(e)));
|
|
368
|
-
}
|
|
369
|
-
onDidGroupModelChange(e) {
|
|
370
|
-
this._onDidModelChange.fire(e);
|
|
371
|
-
if (!e.editor) {
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
switch (e.kind) {
|
|
375
|
-
case 4 :
|
|
376
|
-
if (isGroupEditorOpenEvent(e)) {
|
|
377
|
-
this.onDidOpenEditor(e.editor, e.editorIndex);
|
|
378
|
-
}
|
|
379
|
-
break;
|
|
380
|
-
case 5 :
|
|
381
|
-
if (isGroupEditorCloseEvent(e)) {
|
|
382
|
-
this.handleOnDidCloseEditor(e.editor, e.editorIndex, e.context, e.sticky);
|
|
383
|
-
}
|
|
384
|
-
break;
|
|
385
|
-
case 13 :
|
|
386
|
-
this.onWillDisposeEditor(e.editor);
|
|
387
|
-
break;
|
|
388
|
-
case 12 :
|
|
389
|
-
this.onDidChangeEditorDirty(e.editor);
|
|
390
|
-
break;
|
|
391
|
-
case 8 :
|
|
392
|
-
this.onDidChangeEditorLabel(e.editor);
|
|
393
|
-
break;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
onDidOpenEditor(editor, editorIndex) {
|
|
397
|
-
this.telemetryService.publicLog('editorOpened', this.toEditorTelemetryDescriptor(editor));
|
|
398
|
-
this.updateContainer();
|
|
399
|
-
}
|
|
400
|
-
handleOnDidCloseEditor(editor, editorIndex, context, sticky) {
|
|
401
|
-
this._onWillCloseEditor.fire({ groupId: this.id, editor, context, index: editorIndex, sticky });
|
|
402
|
-
const editorsToClose = [editor];
|
|
403
|
-
if (editor instanceof SideBySideEditorInput) {
|
|
404
|
-
editorsToClose.push(editor.primary, editor.secondary);
|
|
405
|
-
}
|
|
406
|
-
for (const editor of editorsToClose) {
|
|
407
|
-
if (this.canDispose(editor)) {
|
|
408
|
-
editor.dispose();
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
this.telemetryService.publicLog('editorClosed', this.toEditorTelemetryDescriptor(editor));
|
|
412
|
-
this.updateContainer();
|
|
413
|
-
this._onDidCloseEditor.fire({ groupId: this.id, editor, context, index: editorIndex, sticky });
|
|
414
|
-
}
|
|
415
|
-
canDispose(editor) {
|
|
416
|
-
for (const groupView of this.editorPartsView.groups) {
|
|
417
|
-
if (groupView instanceof EditorGroupView_1 && groupView.model.contains(editor, {
|
|
418
|
-
strictEquals: true,
|
|
419
|
-
supportSideBySide: SideBySideEditor.ANY
|
|
420
|
-
})) {
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
return true;
|
|
425
|
-
}
|
|
426
|
-
toEditorTelemetryDescriptor(editor) {
|
|
427
|
-
const descriptor = editor.getTelemetryDescriptor();
|
|
428
|
-
const resource = EditorResourceAccessor.getOriginalUri(editor);
|
|
429
|
-
const path = resource ? resource.scheme === Schemas.file ? resource.fsPath : resource.path : undefined;
|
|
430
|
-
if (resource && path) {
|
|
431
|
-
let resourceExt = extname(resource);
|
|
432
|
-
const queryStringLocation = resourceExt.indexOf('?');
|
|
433
|
-
resourceExt = queryStringLocation !== -1 ? resourceExt.substr(0, queryStringLocation) : resourceExt;
|
|
434
|
-
descriptor['resource'] = { mimeType: ( new TelemetryTrustedValue(getMimeTypes(resource).join(', '))), scheme: resource.scheme, ext: resourceExt, path: hash(path) };
|
|
435
|
-
return descriptor;
|
|
436
|
-
}
|
|
437
|
-
return descriptor;
|
|
438
|
-
}
|
|
439
|
-
onWillDisposeEditor(editor) {
|
|
440
|
-
this.disposedEditorsWorker.work(editor);
|
|
441
|
-
}
|
|
442
|
-
handleDisposedEditors(disposedEditors) {
|
|
443
|
-
let activeEditor;
|
|
444
|
-
const inactiveEditors = [];
|
|
445
|
-
for (const disposedEditor of disposedEditors) {
|
|
446
|
-
const editorFindResult = this.model.findEditor(disposedEditor);
|
|
447
|
-
if (!editorFindResult) {
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
450
|
-
const editor = editorFindResult[0];
|
|
451
|
-
if (!editor.isDisposed()) {
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
if (this.model.isActive(editor)) {
|
|
455
|
-
activeEditor = editor;
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
inactiveEditors.push(editor);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
for (const inactiveEditor of inactiveEditors) {
|
|
462
|
-
this.doCloseEditor(inactiveEditor, true);
|
|
463
|
-
}
|
|
464
|
-
if (activeEditor) {
|
|
465
|
-
this.doCloseEditor(activeEditor, true);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
onDidChangeEditorPartOptions(event) {
|
|
469
|
-
this.updateTitleContainer();
|
|
470
|
-
this.titleControl.updateOptions(event.oldPartOptions, event.newPartOptions);
|
|
471
|
-
if (event.oldPartOptions.showTabs !== event.newPartOptions.showTabs ||
|
|
472
|
-
event.oldPartOptions.tabHeight !== event.newPartOptions.tabHeight ||
|
|
473
|
-
(event.oldPartOptions.showTabs === 'multiple' && event.oldPartOptions.pinnedTabsOnSeparateRow !== event.newPartOptions.pinnedTabsOnSeparateRow)) {
|
|
474
|
-
this.relayout();
|
|
475
|
-
if (this.model.activeEditor) {
|
|
476
|
-
this.titleControl.openEditor(this.model.activeEditor);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
this.updateStyles();
|
|
480
|
-
if (event.oldPartOptions.enablePreview && !event.newPartOptions.enablePreview) {
|
|
481
|
-
if (this.model.previewEditor) {
|
|
482
|
-
this.pinEditor(this.model.previewEditor);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
onDidChangeEditorDirty(editor) {
|
|
487
|
-
this.pinEditor(editor);
|
|
488
|
-
this.titleControl.updateEditorDirty(editor);
|
|
489
|
-
}
|
|
490
|
-
onDidChangeEditorLabel(editor) {
|
|
491
|
-
this.titleControl.updateEditorLabel(editor);
|
|
492
|
-
}
|
|
493
|
-
onDidVisibilityChange(visible) {
|
|
494
|
-
this.editorPane.setVisible(visible);
|
|
495
|
-
}
|
|
496
|
-
get index() {
|
|
497
|
-
return this._index;
|
|
498
|
-
}
|
|
499
|
-
get label() {
|
|
500
|
-
if (this.groupsLabel) {
|
|
501
|
-
return ( localizeWithPath(
|
|
502
|
-
'vs/workbench/browser/parts/editor/editorGroupView',
|
|
503
|
-
'groupLabelLong',
|
|
504
|
-
"{0}: Group {1}",
|
|
505
|
-
this.groupsLabel,
|
|
506
|
-
this._index + 1
|
|
507
|
-
));
|
|
508
|
-
}
|
|
509
|
-
return ( localizeWithPath(
|
|
510
|
-
'vs/workbench/browser/parts/editor/editorGroupView',
|
|
511
|
-
'groupLabel',
|
|
512
|
-
"Group {0}",
|
|
513
|
-
this._index + 1
|
|
514
|
-
));
|
|
515
|
-
}
|
|
516
|
-
get ariaLabel() {
|
|
517
|
-
if (this.groupsLabel) {
|
|
518
|
-
return ( localizeWithPath(
|
|
519
|
-
'vs/workbench/browser/parts/editor/editorGroupView',
|
|
520
|
-
'groupAriaLabelLong',
|
|
521
|
-
"{0}: Editor Group {1}",
|
|
522
|
-
this.groupsLabel,
|
|
523
|
-
this._index + 1
|
|
524
|
-
));
|
|
525
|
-
}
|
|
526
|
-
return ( localizeWithPath(
|
|
527
|
-
'vs/workbench/browser/parts/editor/editorGroupView',
|
|
528
|
-
'groupAriaLabel',
|
|
529
|
-
"Editor Group {0}",
|
|
530
|
-
this._index + 1
|
|
531
|
-
));
|
|
532
|
-
}
|
|
533
|
-
get disposed() {
|
|
534
|
-
return this._disposed;
|
|
535
|
-
}
|
|
536
|
-
get isEmpty() {
|
|
537
|
-
return this.count === 0;
|
|
538
|
-
}
|
|
539
|
-
get titleHeight() {
|
|
540
|
-
return this.titleControl.getHeight();
|
|
541
|
-
}
|
|
542
|
-
notifyIndexChanged(newIndex) {
|
|
543
|
-
if (this._index !== newIndex) {
|
|
544
|
-
this._index = newIndex;
|
|
545
|
-
this.model.setIndex(newIndex);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
notifyLabelChanged(newLabel) {
|
|
549
|
-
if (this.groupsLabel !== newLabel) {
|
|
550
|
-
this.groupsLabel = newLabel;
|
|
551
|
-
this.model.setLabel(newLabel);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
setActive(isActive) {
|
|
555
|
-
this.active = isActive;
|
|
556
|
-
this.element.classList.toggle('active', isActive);
|
|
557
|
-
this.element.classList.toggle('inactive', !isActive);
|
|
558
|
-
this.titleControl.setActive(isActive);
|
|
559
|
-
this.updateStyles();
|
|
560
|
-
this.model.setActive(undefined );
|
|
561
|
-
}
|
|
562
|
-
get id() {
|
|
563
|
-
return this.model.id;
|
|
564
|
-
}
|
|
565
|
-
get editors() {
|
|
566
|
-
return this.model.getEditors(1 );
|
|
567
|
-
}
|
|
568
|
-
get count() {
|
|
569
|
-
return this.model.count;
|
|
570
|
-
}
|
|
571
|
-
get stickyCount() {
|
|
572
|
-
return this.model.stickyCount;
|
|
573
|
-
}
|
|
574
|
-
get activeEditorPane() {
|
|
575
|
-
return this.editorPane ? this.editorPane.activeEditorPane ?? undefined : undefined;
|
|
576
|
-
}
|
|
577
|
-
get activeEditor() {
|
|
578
|
-
return this.model.activeEditor;
|
|
579
|
-
}
|
|
580
|
-
get previewEditor() {
|
|
581
|
-
return this.model.previewEditor;
|
|
582
|
-
}
|
|
583
|
-
isPinned(editorOrIndex) {
|
|
584
|
-
return this.model.isPinned(editorOrIndex);
|
|
585
|
-
}
|
|
586
|
-
isSticky(editorOrIndex) {
|
|
587
|
-
return this.model.isSticky(editorOrIndex);
|
|
588
|
-
}
|
|
589
|
-
isActive(editor) {
|
|
590
|
-
return this.model.isActive(editor);
|
|
591
|
-
}
|
|
592
|
-
contains(candidate, options) {
|
|
593
|
-
return this.model.contains(candidate, options);
|
|
594
|
-
}
|
|
595
|
-
getEditors(order, options) {
|
|
596
|
-
return this.model.getEditors(order, options);
|
|
597
|
-
}
|
|
598
|
-
findEditors(resource, options) {
|
|
599
|
-
const canonicalResource = this.uriIdentityService.asCanonicalUri(resource);
|
|
600
|
-
return this.getEditors(1 ).filter(editor => {
|
|
601
|
-
if (editor.resource && isEqual(editor.resource, canonicalResource)) {
|
|
602
|
-
return true;
|
|
603
|
-
}
|
|
604
|
-
if (options?.supportSideBySide === SideBySideEditor.PRIMARY || options?.supportSideBySide === SideBySideEditor.ANY) {
|
|
605
|
-
const primaryResource = EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.PRIMARY });
|
|
606
|
-
if (primaryResource && isEqual(primaryResource, canonicalResource)) {
|
|
607
|
-
return true;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
if (options?.supportSideBySide === SideBySideEditor.SECONDARY || options?.supportSideBySide === SideBySideEditor.ANY) {
|
|
611
|
-
const secondaryResource = EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.SECONDARY });
|
|
612
|
-
if (secondaryResource && isEqual(secondaryResource, canonicalResource)) {
|
|
613
|
-
return true;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
return false;
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
getEditorByIndex(index) {
|
|
620
|
-
return this.model.getEditorByIndex(index);
|
|
621
|
-
}
|
|
622
|
-
getIndexOfEditor(editor) {
|
|
623
|
-
return this.model.indexOf(editor);
|
|
624
|
-
}
|
|
625
|
-
isFirst(editor) {
|
|
626
|
-
return this.model.isFirst(editor);
|
|
627
|
-
}
|
|
628
|
-
isLast(editor) {
|
|
629
|
-
return this.model.isLast(editor);
|
|
630
|
-
}
|
|
631
|
-
focus() {
|
|
632
|
-
focusWindow(this.element);
|
|
633
|
-
if (this.activeEditorPane) {
|
|
634
|
-
this.activeEditorPane.focus();
|
|
635
|
-
}
|
|
636
|
-
else {
|
|
637
|
-
this.element.focus();
|
|
638
|
-
}
|
|
639
|
-
this._onDidFocus.fire();
|
|
640
|
-
}
|
|
641
|
-
pinEditor(candidate = this.activeEditor || undefined) {
|
|
642
|
-
if (candidate && !this.model.isPinned(candidate)) {
|
|
643
|
-
const editor = this.model.pin(candidate);
|
|
644
|
-
if (editor) {
|
|
645
|
-
this.titleControl.pinEditor(editor);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
stickEditor(candidate = this.activeEditor || undefined) {
|
|
650
|
-
this.doStickEditor(candidate, true);
|
|
651
|
-
}
|
|
652
|
-
unstickEditor(candidate = this.activeEditor || undefined) {
|
|
653
|
-
this.doStickEditor(candidate, false);
|
|
654
|
-
}
|
|
655
|
-
doStickEditor(candidate, sticky) {
|
|
656
|
-
if (candidate && this.model.isSticky(candidate) !== sticky) {
|
|
657
|
-
const oldIndexOfEditor = this.getIndexOfEditor(candidate);
|
|
658
|
-
const editor = sticky ? this.model.stick(candidate) : this.model.unstick(candidate);
|
|
659
|
-
if (!editor) {
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
const newIndexOfEditor = this.getIndexOfEditor(editor);
|
|
663
|
-
if (newIndexOfEditor !== oldIndexOfEditor) {
|
|
664
|
-
this.titleControl.moveEditor(editor, oldIndexOfEditor, newIndexOfEditor, true);
|
|
665
|
-
}
|
|
666
|
-
if (sticky) {
|
|
667
|
-
this.titleControl.stickEditor(editor);
|
|
668
|
-
}
|
|
669
|
-
else {
|
|
670
|
-
this.titleControl.unstickEditor(editor);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
async openEditor(editor, options, internalOptions) {
|
|
675
|
-
return this.doOpenEditor(editor, options, {
|
|
676
|
-
...internalOptions,
|
|
677
|
-
supportSideBySide: SideBySideEditor.BOTH
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
async doOpenEditor(editor, options, internalOptions) {
|
|
681
|
-
if (!editor || editor.isDisposed()) {
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
|
-
this._onWillOpenEditor.fire({ editor, groupId: this.id });
|
|
685
|
-
const pinned = options?.sticky
|
|
686
|
-
|| !this.groupsView.partOptions.enablePreview
|
|
687
|
-
|| editor.isDirty()
|
|
688
|
-
|| ((options?.pinned ?? typeof options?.index === 'number') )
|
|
689
|
-
|| (typeof options?.index === 'number' && this.model.isSticky(options.index))
|
|
690
|
-
|| editor.hasCapability(512 );
|
|
691
|
-
const openEditorOptions = {
|
|
692
|
-
index: options ? options.index : undefined,
|
|
693
|
-
pinned,
|
|
694
|
-
sticky: options?.sticky || (typeof options?.index === 'number' && this.model.isSticky(options.index)),
|
|
695
|
-
active: this.count === 0 || !options || !options.inactive,
|
|
696
|
-
supportSideBySide: internalOptions?.supportSideBySide
|
|
697
|
-
};
|
|
698
|
-
if (!openEditorOptions.active && !openEditorOptions.pinned && this.model.activeEditor && !this.model.isPinned(this.model.activeEditor)) {
|
|
699
|
-
openEditorOptions.active = true;
|
|
700
|
-
}
|
|
701
|
-
let activateGroup = false;
|
|
702
|
-
let restoreGroup = false;
|
|
703
|
-
if (options?.activation === EditorActivation.ACTIVATE) {
|
|
704
|
-
activateGroup = true;
|
|
705
|
-
}
|
|
706
|
-
else if (options?.activation === EditorActivation.RESTORE) {
|
|
707
|
-
restoreGroup = true;
|
|
708
|
-
}
|
|
709
|
-
else if (options?.activation === EditorActivation.PRESERVE) {
|
|
710
|
-
activateGroup = false;
|
|
711
|
-
restoreGroup = false;
|
|
712
|
-
}
|
|
713
|
-
else if (openEditorOptions.active) {
|
|
714
|
-
activateGroup = !options || !options.preserveFocus;
|
|
715
|
-
restoreGroup = !activateGroup;
|
|
716
|
-
}
|
|
717
|
-
if (typeof openEditorOptions.index === 'number') {
|
|
718
|
-
const indexOfEditor = this.model.indexOf(editor);
|
|
719
|
-
if (indexOfEditor !== -1 && indexOfEditor !== openEditorOptions.index) {
|
|
720
|
-
this.doMoveEditorInsideGroup(editor, openEditorOptions);
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
const { editor: openedEditor, isNew } = this.model.openEditor(editor, openEditorOptions);
|
|
724
|
-
if (isNew &&
|
|
725
|
-
this.count === 1 &&
|
|
726
|
-
this.canLock()
|
|
727
|
-
) {
|
|
728
|
-
if (openedEditor.editorId && this.groupsView.partOptions.autoLockGroups?.has(openedEditor.editorId)) {
|
|
729
|
-
this.lock(true);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
const showEditorResult = this.doShowEditor(openedEditor, { active: !!openEditorOptions.active, isNew }, options, internalOptions);
|
|
733
|
-
if (activateGroup) {
|
|
734
|
-
this.groupsView.activateGroup(this);
|
|
735
|
-
}
|
|
736
|
-
else if (restoreGroup) {
|
|
737
|
-
this.groupsView.restoreGroup(this);
|
|
738
|
-
}
|
|
739
|
-
return showEditorResult;
|
|
740
|
-
}
|
|
741
|
-
doShowEditor(editor, context, options, internalOptions) {
|
|
742
|
-
let openEditorPromise;
|
|
743
|
-
if (context.active) {
|
|
744
|
-
openEditorPromise = (async () => {
|
|
745
|
-
const { pane, changed, cancelled, error } = await this.editorPane.openEditor(editor, options, internalOptions, { newInGroup: context.isNew });
|
|
746
|
-
if (cancelled) {
|
|
747
|
-
return undefined;
|
|
748
|
-
}
|
|
749
|
-
if (changed) {
|
|
750
|
-
this._onDidActiveEditorChange.fire({ editor });
|
|
751
|
-
}
|
|
752
|
-
if (error) {
|
|
753
|
-
this._onDidOpenEditorFail.fire(editor);
|
|
754
|
-
}
|
|
755
|
-
if (!pane && this.activeEditor === editor) {
|
|
756
|
-
this.doCloseEditor(editor, options?.preserveFocus, { fromError: true });
|
|
757
|
-
}
|
|
758
|
-
return pane;
|
|
759
|
-
})();
|
|
760
|
-
}
|
|
761
|
-
else {
|
|
762
|
-
openEditorPromise = Promise.resolve(undefined);
|
|
763
|
-
}
|
|
764
|
-
if (!internalOptions?.skipTitleUpdate) {
|
|
765
|
-
this.titleControl.openEditor(editor, internalOptions);
|
|
766
|
-
}
|
|
767
|
-
return openEditorPromise;
|
|
768
|
-
}
|
|
769
|
-
async openEditors(editors) {
|
|
770
|
-
const editorsToOpen = coalesce(editors).filter(({ editor }) => !editor.isDisposed());
|
|
771
|
-
const firstEditor = firstOrDefault(editorsToOpen);
|
|
772
|
-
if (!firstEditor) {
|
|
773
|
-
return;
|
|
774
|
-
}
|
|
775
|
-
const openEditorsOptions = {
|
|
776
|
-
supportSideBySide: SideBySideEditor.BOTH
|
|
777
|
-
};
|
|
778
|
-
await this.doOpenEditor(firstEditor.editor, firstEditor.options, openEditorsOptions);
|
|
779
|
-
const inactiveEditors = editorsToOpen.slice(1);
|
|
780
|
-
const startingIndex = this.getIndexOfEditor(firstEditor.editor) + 1;
|
|
781
|
-
await Promises.settled(( inactiveEditors.map(({ editor, options }, index) => {
|
|
782
|
-
return this.doOpenEditor(editor, {
|
|
783
|
-
...options,
|
|
784
|
-
inactive: true,
|
|
785
|
-
pinned: true,
|
|
786
|
-
index: startingIndex + index
|
|
787
|
-
}, {
|
|
788
|
-
...openEditorsOptions,
|
|
789
|
-
skipTitleUpdate: true
|
|
790
|
-
});
|
|
791
|
-
})));
|
|
792
|
-
this.titleControl.openEditors(( inactiveEditors.map(({ editor }) => editor)));
|
|
793
|
-
return this.editorPane.activeEditorPane ?? undefined;
|
|
794
|
-
}
|
|
795
|
-
moveEditors(editors, target) {
|
|
796
|
-
const internalOptions = {
|
|
797
|
-
skipTitleUpdate: this !== target
|
|
798
|
-
};
|
|
799
|
-
for (const { editor, options } of editors) {
|
|
800
|
-
this.moveEditor(editor, target, options, internalOptions);
|
|
801
|
-
}
|
|
802
|
-
if (internalOptions.skipTitleUpdate) {
|
|
803
|
-
const movedEditors = ( editors.map(({ editor }) => editor));
|
|
804
|
-
target.titleControl.openEditors(movedEditors);
|
|
805
|
-
this.titleControl.closeEditors(movedEditors);
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
moveEditor(editor, target, options, internalOptions) {
|
|
809
|
-
if (this === target) {
|
|
810
|
-
this.doMoveEditorInsideGroup(editor, options);
|
|
811
|
-
}
|
|
812
|
-
else {
|
|
813
|
-
this.doMoveOrCopyEditorAcrossGroups(editor, target, options, { ...internalOptions, keepCopy: false });
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
doMoveEditorInsideGroup(candidate, options) {
|
|
817
|
-
const moveToIndex = options ? options.index : undefined;
|
|
818
|
-
if (typeof moveToIndex !== 'number') {
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
const currentIndex = this.model.indexOf(candidate);
|
|
822
|
-
const editor = this.model.getEditorByIndex(currentIndex);
|
|
823
|
-
if (!editor) {
|
|
824
|
-
return;
|
|
825
|
-
}
|
|
826
|
-
if (currentIndex !== moveToIndex) {
|
|
827
|
-
const oldStickyCount = this.model.stickyCount;
|
|
828
|
-
this.model.moveEditor(editor, moveToIndex);
|
|
829
|
-
this.model.pin(editor);
|
|
830
|
-
this.titleControl.moveEditor(editor, currentIndex, moveToIndex, oldStickyCount !== this.model.stickyCount);
|
|
831
|
-
this.titleControl.pinEditor(editor);
|
|
832
|
-
}
|
|
833
|
-
if (options?.sticky) {
|
|
834
|
-
this.stickEditor(editor);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
doMoveOrCopyEditorAcrossGroups(editor, target, openOptions, internalOptions) {
|
|
838
|
-
const keepCopy = internalOptions?.keepCopy;
|
|
839
|
-
const options = fillActiveEditorViewState(this, editor, {
|
|
840
|
-
...openOptions,
|
|
841
|
-
pinned: true,
|
|
842
|
-
sticky: openOptions?.sticky ?? (!keepCopy && this.model.isSticky(editor))
|
|
843
|
-
});
|
|
844
|
-
if (!keepCopy) {
|
|
845
|
-
this._onWillMoveEditor.fire({
|
|
846
|
-
groupId: this.id,
|
|
847
|
-
editor,
|
|
848
|
-
target: target.id
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
target.doOpenEditor(keepCopy ? editor.copy() : editor, options, internalOptions);
|
|
852
|
-
if (!keepCopy) {
|
|
853
|
-
this.doCloseEditor(editor, true , { ...internalOptions, context: EditorCloseContext.MOVE });
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
copyEditors(editors, target) {
|
|
857
|
-
const internalOptions = {
|
|
858
|
-
skipTitleUpdate: this !== target
|
|
859
|
-
};
|
|
860
|
-
for (const { editor, options } of editors) {
|
|
861
|
-
this.copyEditor(editor, target, options, internalOptions);
|
|
862
|
-
}
|
|
863
|
-
if (internalOptions.skipTitleUpdate) {
|
|
864
|
-
const copiedEditors = ( editors.map(({ editor }) => editor));
|
|
865
|
-
target.titleControl.openEditors(copiedEditors);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
copyEditor(editor, target, options, internalOptions) {
|
|
869
|
-
if (this === target) {
|
|
870
|
-
this.doMoveEditorInsideGroup(editor, options);
|
|
871
|
-
}
|
|
872
|
-
else {
|
|
873
|
-
this.doMoveOrCopyEditorAcrossGroups(editor, target, options, { ...internalOptions, keepCopy: true });
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
async closeEditor(editor = this.activeEditor || undefined, options) {
|
|
877
|
-
return this.doCloseEditorWithConfirmationHandling(editor, options);
|
|
878
|
-
}
|
|
879
|
-
async doCloseEditorWithConfirmationHandling(editor = this.activeEditor || undefined, options, internalOptions) {
|
|
880
|
-
if (!editor) {
|
|
881
|
-
return false;
|
|
882
|
-
}
|
|
883
|
-
const veto = await this.handleCloseConfirmation([editor]);
|
|
884
|
-
if (veto) {
|
|
885
|
-
return false;
|
|
886
|
-
}
|
|
887
|
-
this.doCloseEditor(editor, options?.preserveFocus, internalOptions);
|
|
888
|
-
return true;
|
|
889
|
-
}
|
|
890
|
-
doCloseEditor(editor, preserveFocus = (this.groupsView.activeGroup !== this), internalOptions) {
|
|
891
|
-
if (!internalOptions?.skipTitleUpdate) {
|
|
892
|
-
this.titleControl.beforeCloseEditor(editor);
|
|
893
|
-
}
|
|
894
|
-
if (this.model.isActive(editor)) {
|
|
895
|
-
this.doCloseActiveEditor(preserveFocus, internalOptions);
|
|
896
|
-
}
|
|
897
|
-
else {
|
|
898
|
-
this.doCloseInactiveEditor(editor, internalOptions);
|
|
899
|
-
}
|
|
900
|
-
if (!internalOptions?.skipTitleUpdate) {
|
|
901
|
-
this.titleControl.closeEditor(editor);
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
doCloseActiveEditor(preserveFocus = (this.groupsView.activeGroup !== this), internalOptions) {
|
|
905
|
-
const editorToClose = this.activeEditor;
|
|
906
|
-
const restoreFocus = !preserveFocus && this.shouldRestoreFocus(this.element);
|
|
907
|
-
const closeEmptyGroup = this.groupsView.partOptions.closeEmptyGroups;
|
|
908
|
-
if (closeEmptyGroup && this.active && this.count === 1) {
|
|
909
|
-
const mostRecentlyActiveGroups = this.groupsView.getGroups(1 );
|
|
910
|
-
const nextActiveGroup = mostRecentlyActiveGroups[1];
|
|
911
|
-
if (nextActiveGroup) {
|
|
912
|
-
if (restoreFocus) {
|
|
913
|
-
nextActiveGroup.focus();
|
|
914
|
-
}
|
|
915
|
-
else {
|
|
916
|
-
this.groupsView.activateGroup(nextActiveGroup, true);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
if (editorToClose) {
|
|
921
|
-
this.model.closeEditor(editorToClose, internalOptions?.context);
|
|
922
|
-
}
|
|
923
|
-
const nextActiveEditor = this.model.activeEditor;
|
|
924
|
-
if (nextActiveEditor) {
|
|
925
|
-
let activation = undefined;
|
|
926
|
-
if (preserveFocus && this.groupsView.activeGroup !== this) {
|
|
927
|
-
activation = EditorActivation.PRESERVE;
|
|
928
|
-
}
|
|
929
|
-
const options = {
|
|
930
|
-
preserveFocus,
|
|
931
|
-
activation,
|
|
932
|
-
ignoreError: internalOptions?.fromError
|
|
933
|
-
};
|
|
934
|
-
const internalEditorOpenOptions = {
|
|
935
|
-
preserveWindowOrder: true
|
|
936
|
-
};
|
|
937
|
-
this.doOpenEditor(nextActiveEditor, options, internalEditorOpenOptions);
|
|
938
|
-
}
|
|
939
|
-
else {
|
|
940
|
-
if (editorToClose) {
|
|
941
|
-
this.editorPane.closeEditor(editorToClose);
|
|
942
|
-
}
|
|
943
|
-
if (restoreFocus && !closeEmptyGroup) {
|
|
944
|
-
this.focus();
|
|
945
|
-
}
|
|
946
|
-
this._onDidActiveEditorChange.fire({ editor: undefined });
|
|
947
|
-
if (closeEmptyGroup) {
|
|
948
|
-
this.groupsView.removeGroup(this, preserveFocus);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
shouldRestoreFocus(target) {
|
|
953
|
-
const activeElement = target.ownerDocument.activeElement;
|
|
954
|
-
if (activeElement === target.ownerDocument.body) {
|
|
955
|
-
return true;
|
|
956
|
-
}
|
|
957
|
-
return isAncestor(activeElement, target);
|
|
958
|
-
}
|
|
959
|
-
doCloseInactiveEditor(editor, internalOptions) {
|
|
960
|
-
this.model.closeEditor(editor, internalOptions?.context);
|
|
961
|
-
}
|
|
962
|
-
async handleCloseConfirmation(editors) {
|
|
963
|
-
if (!editors.length) {
|
|
964
|
-
return false;
|
|
965
|
-
}
|
|
966
|
-
const editor = editors.shift();
|
|
967
|
-
let handleCloseConfirmationPromise = this.mapEditorToPendingConfirmation.get(editor);
|
|
968
|
-
if (!handleCloseConfirmationPromise) {
|
|
969
|
-
handleCloseConfirmationPromise = this.doHandleCloseConfirmation(editor);
|
|
970
|
-
this.mapEditorToPendingConfirmation.set(editor, handleCloseConfirmationPromise);
|
|
971
|
-
}
|
|
972
|
-
let veto;
|
|
973
|
-
try {
|
|
974
|
-
veto = await handleCloseConfirmationPromise;
|
|
975
|
-
}
|
|
976
|
-
finally {
|
|
977
|
-
this.mapEditorToPendingConfirmation.delete(editor);
|
|
978
|
-
}
|
|
979
|
-
if (veto) {
|
|
980
|
-
return veto;
|
|
981
|
-
}
|
|
982
|
-
return this.handleCloseConfirmation(editors);
|
|
983
|
-
}
|
|
984
|
-
async doHandleCloseConfirmation(editor, options) {
|
|
985
|
-
if (!this.shouldConfirmClose(editor)) {
|
|
986
|
-
return false;
|
|
987
|
-
}
|
|
988
|
-
if (editor instanceof SideBySideEditorInput && this.model.contains(editor.primary)) {
|
|
989
|
-
return false;
|
|
990
|
-
}
|
|
991
|
-
if (( this.editorPartsView.groups.some(groupView => {
|
|
992
|
-
if (groupView === this) {
|
|
993
|
-
return false;
|
|
994
|
-
}
|
|
995
|
-
const otherGroup = groupView;
|
|
996
|
-
if (otherGroup.contains(editor, { supportSideBySide: SideBySideEditor.BOTH })) {
|
|
997
|
-
return true;
|
|
998
|
-
}
|
|
999
|
-
if (editor instanceof SideBySideEditorInput && otherGroup.contains(editor.primary)) {
|
|
1000
|
-
return true;
|
|
1001
|
-
}
|
|
1002
|
-
return false;
|
|
1003
|
-
}))) {
|
|
1004
|
-
return false;
|
|
1005
|
-
}
|
|
1006
|
-
let confirmation = 2 ;
|
|
1007
|
-
let saveReason = 1 ;
|
|
1008
|
-
let autoSave = false;
|
|
1009
|
-
if (!editor.hasCapability(4 ) && !options?.skipAutoSave && !editor.closeHandler) {
|
|
1010
|
-
if (this.filesConfigurationService.getAutoSaveMode() === 3 ) {
|
|
1011
|
-
autoSave = true;
|
|
1012
|
-
confirmation = 0 ;
|
|
1013
|
-
saveReason = 3 ;
|
|
1014
|
-
}
|
|
1015
|
-
else if ((isNative && (isWindows || isLinux)) && this.filesConfigurationService.getAutoSaveMode() === 4 ) {
|
|
1016
|
-
autoSave = true;
|
|
1017
|
-
confirmation = 0 ;
|
|
1018
|
-
saveReason = 4 ;
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
if (!autoSave) {
|
|
1022
|
-
if (!this.activeEditor || !this.activeEditor.matches(editor)) {
|
|
1023
|
-
await this.doOpenEditor(editor);
|
|
1024
|
-
}
|
|
1025
|
-
if (typeof editor.closeHandler?.confirm === 'function') {
|
|
1026
|
-
confirmation = await editor.closeHandler.confirm([{ editor, groupId: this.id }]);
|
|
1027
|
-
}
|
|
1028
|
-
else {
|
|
1029
|
-
let name;
|
|
1030
|
-
if (editor instanceof SideBySideEditorInput) {
|
|
1031
|
-
name = editor.primary.getName();
|
|
1032
|
-
}
|
|
1033
|
-
else {
|
|
1034
|
-
name = editor.getName();
|
|
1035
|
-
}
|
|
1036
|
-
confirmation = await this.fileDialogService.showSaveConfirm([name]);
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
if (!editor.closeHandler && !this.shouldConfirmClose(editor)) {
|
|
1040
|
-
return confirmation === 2 ? true : false;
|
|
1041
|
-
}
|
|
1042
|
-
switch (confirmation) {
|
|
1043
|
-
case 0 : {
|
|
1044
|
-
const result = await editor.save(this.id, { reason: saveReason });
|
|
1045
|
-
if (!result && autoSave) {
|
|
1046
|
-
return this.doHandleCloseConfirmation(editor, { skipAutoSave: true });
|
|
1047
|
-
}
|
|
1048
|
-
return editor.isDirty();
|
|
1049
|
-
}
|
|
1050
|
-
case 1 :
|
|
1051
|
-
try {
|
|
1052
|
-
await editor.revert(this.id);
|
|
1053
|
-
return editor.isDirty();
|
|
1054
|
-
}
|
|
1055
|
-
catch (error) {
|
|
1056
|
-
this.logService.error(error);
|
|
1057
|
-
await editor.revert(this.id, { soft: true });
|
|
1058
|
-
return editor.isDirty();
|
|
1059
|
-
}
|
|
1060
|
-
case 2 :
|
|
1061
|
-
return true;
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
shouldConfirmClose(editor) {
|
|
1065
|
-
if (editor.closeHandler) {
|
|
1066
|
-
return editor.closeHandler.showConfirm();
|
|
1067
|
-
}
|
|
1068
|
-
return editor.isDirty() && !editor.isSaving();
|
|
1069
|
-
}
|
|
1070
|
-
async closeEditors(args, options) {
|
|
1071
|
-
if (this.isEmpty) {
|
|
1072
|
-
return true;
|
|
1073
|
-
}
|
|
1074
|
-
const editors = this.doGetEditorsToClose(args);
|
|
1075
|
-
const veto = await this.handleCloseConfirmation(editors.slice(0));
|
|
1076
|
-
if (veto) {
|
|
1077
|
-
return false;
|
|
1078
|
-
}
|
|
1079
|
-
this.doCloseEditors(editors, options);
|
|
1080
|
-
return true;
|
|
1081
|
-
}
|
|
1082
|
-
doGetEditorsToClose(args) {
|
|
1083
|
-
if (Array.isArray(args)) {
|
|
1084
|
-
return args;
|
|
1085
|
-
}
|
|
1086
|
-
const filter = args;
|
|
1087
|
-
const hasDirection = typeof filter.direction === 'number';
|
|
1088
|
-
let editorsToClose = this.model.getEditors(hasDirection ? 1 : 0 , filter);
|
|
1089
|
-
if (filter.savedOnly) {
|
|
1090
|
-
editorsToClose = editorsToClose.filter(editor => !editor.isDirty() || editor.isSaving());
|
|
1091
|
-
}
|
|
1092
|
-
else if (hasDirection && filter.except) {
|
|
1093
|
-
editorsToClose = ((filter.direction === 0) ) ?
|
|
1094
|
-
editorsToClose.slice(0, this.model.indexOf(filter.except, editorsToClose)) :
|
|
1095
|
-
editorsToClose.slice(this.model.indexOf(filter.except, editorsToClose) + 1);
|
|
1096
|
-
}
|
|
1097
|
-
else if (filter.except) {
|
|
1098
|
-
editorsToClose = editorsToClose.filter(editor => filter.except && !editor.matches(filter.except));
|
|
1099
|
-
}
|
|
1100
|
-
return editorsToClose;
|
|
1101
|
-
}
|
|
1102
|
-
doCloseEditors(editors, options) {
|
|
1103
|
-
let closeActiveEditor = false;
|
|
1104
|
-
for (const editor of editors) {
|
|
1105
|
-
if (!this.isActive(editor)) {
|
|
1106
|
-
this.doCloseInactiveEditor(editor);
|
|
1107
|
-
}
|
|
1108
|
-
else {
|
|
1109
|
-
closeActiveEditor = true;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
if (closeActiveEditor) {
|
|
1113
|
-
this.doCloseActiveEditor(options?.preserveFocus);
|
|
1114
|
-
}
|
|
1115
|
-
if (editors.length) {
|
|
1116
|
-
this.titleControl.closeEditors(editors);
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
async closeAllEditors(options) {
|
|
1120
|
-
if (this.isEmpty) {
|
|
1121
|
-
if (this.groupsView.partOptions.closeEmptyGroups) {
|
|
1122
|
-
this.groupsView.removeGroup(this);
|
|
1123
|
-
}
|
|
1124
|
-
return true;
|
|
1125
|
-
}
|
|
1126
|
-
const veto = await this.handleCloseConfirmation(this.model.getEditors(0 , options));
|
|
1127
|
-
if (veto) {
|
|
1128
|
-
return false;
|
|
1129
|
-
}
|
|
1130
|
-
this.doCloseAllEditors(options);
|
|
1131
|
-
return true;
|
|
1132
|
-
}
|
|
1133
|
-
doCloseAllEditors(options) {
|
|
1134
|
-
const editorsToClose = [];
|
|
1135
|
-
for (const editor of this.model.getEditors(1 , options)) {
|
|
1136
|
-
if (!this.isActive(editor)) {
|
|
1137
|
-
this.doCloseInactiveEditor(editor);
|
|
1138
|
-
}
|
|
1139
|
-
editorsToClose.push(editor);
|
|
1140
|
-
}
|
|
1141
|
-
if (this.activeEditor && editorsToClose.includes(this.activeEditor)) {
|
|
1142
|
-
this.doCloseActiveEditor();
|
|
1143
|
-
}
|
|
1144
|
-
if (editorsToClose.length) {
|
|
1145
|
-
this.titleControl.closeEditors(editorsToClose);
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
async replaceEditors(editors) {
|
|
1149
|
-
let activeReplacement;
|
|
1150
|
-
const inactiveReplacements = [];
|
|
1151
|
-
for (let { editor, replacement, forceReplaceDirty, options } of editors) {
|
|
1152
|
-
const index = this.getIndexOfEditor(editor);
|
|
1153
|
-
if (index >= 0) {
|
|
1154
|
-
const isActiveEditor = this.isActive(editor);
|
|
1155
|
-
if (options) {
|
|
1156
|
-
options.index = index;
|
|
1157
|
-
}
|
|
1158
|
-
else {
|
|
1159
|
-
options = { index };
|
|
1160
|
-
}
|
|
1161
|
-
options.inactive = !isActiveEditor;
|
|
1162
|
-
options.pinned = options.pinned ?? true;
|
|
1163
|
-
const editorToReplace = { editor, replacement, forceReplaceDirty, options };
|
|
1164
|
-
if (isActiveEditor) {
|
|
1165
|
-
activeReplacement = editorToReplace;
|
|
1166
|
-
}
|
|
1167
|
-
else {
|
|
1168
|
-
inactiveReplacements.push(editorToReplace);
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
for (const { editor, replacement, forceReplaceDirty, options } of inactiveReplacements) {
|
|
1173
|
-
await this.doOpenEditor(replacement, options);
|
|
1174
|
-
if (!editor.matches(replacement)) {
|
|
1175
|
-
let closed = false;
|
|
1176
|
-
if (forceReplaceDirty) {
|
|
1177
|
-
this.doCloseEditor(editor, true, { context: EditorCloseContext.REPLACE });
|
|
1178
|
-
closed = true;
|
|
1179
|
-
}
|
|
1180
|
-
else {
|
|
1181
|
-
closed = await this.doCloseEditorWithConfirmationHandling(editor, { preserveFocus: true }, { context: EditorCloseContext.REPLACE });
|
|
1182
|
-
}
|
|
1183
|
-
if (!closed) {
|
|
1184
|
-
return;
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
if (activeReplacement) {
|
|
1189
|
-
const openEditorResult = this.doOpenEditor(activeReplacement.replacement, activeReplacement.options);
|
|
1190
|
-
if (!activeReplacement.editor.matches(activeReplacement.replacement)) {
|
|
1191
|
-
if (activeReplacement.forceReplaceDirty) {
|
|
1192
|
-
this.doCloseEditor(activeReplacement.editor, true, { context: EditorCloseContext.REPLACE });
|
|
1193
|
-
}
|
|
1194
|
-
else {
|
|
1195
|
-
await this.doCloseEditorWithConfirmationHandling(activeReplacement.editor, { preserveFocus: true }, { context: EditorCloseContext.REPLACE });
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
await openEditorResult;
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
get isLocked() {
|
|
1202
|
-
if (!this.canLock()) {
|
|
1203
|
-
return false;
|
|
1204
|
-
}
|
|
1205
|
-
return this.model.isLocked;
|
|
1206
|
-
}
|
|
1207
|
-
lock(locked) {
|
|
1208
|
-
if (!this.canLock()) {
|
|
1209
|
-
locked = false;
|
|
1210
|
-
}
|
|
1211
|
-
this.model.lock(locked);
|
|
1212
|
-
}
|
|
1213
|
-
canLock() {
|
|
1214
|
-
if (this.groupsView.isAuxiliary) {
|
|
1215
|
-
return true;
|
|
1216
|
-
}
|
|
1217
|
-
return this.groupsView.groups.length > 1;
|
|
1218
|
-
}
|
|
1219
|
-
createEditorActions(disposables) {
|
|
1220
|
-
const primary = [];
|
|
1221
|
-
const secondary = [];
|
|
1222
|
-
let onDidChange;
|
|
1223
|
-
const activeEditorPane = this.activeEditorPane;
|
|
1224
|
-
if (activeEditorPane instanceof EditorPane) {
|
|
1225
|
-
const editorScopedContextKeyService = activeEditorPane.scopedContextKeyService ?? this.scopedContextKeyService;
|
|
1226
|
-
const editorTitleMenu = disposables.add(this.menuService.createMenu(MenuId.EditorTitle, editorScopedContextKeyService, { emitEventsForSubmenuChanges: true, eventDebounceDelay: 0 }));
|
|
1227
|
-
onDidChange = editorTitleMenu.onDidChange;
|
|
1228
|
-
const shouldInlineGroup = (action, group) => group === 'navigation' && action.actions.length <= 1;
|
|
1229
|
-
createAndFillInActionBarActions(editorTitleMenu, { arg: this.resourceContext.get(), shouldForwardArgs: true }, { primary, secondary }, 'navigation', shouldInlineGroup);
|
|
1230
|
-
}
|
|
1231
|
-
else {
|
|
1232
|
-
const _onDidChange = disposables.add(( new Emitter()));
|
|
1233
|
-
onDidChange = _onDidChange.event;
|
|
1234
|
-
disposables.add(this.onDidActiveEditorChange(() => _onDidChange.fire()));
|
|
1235
|
-
}
|
|
1236
|
-
return { actions: { primary, secondary }, onDidChange };
|
|
1237
|
-
}
|
|
1238
|
-
updateStyles() {
|
|
1239
|
-
const isEmpty = this.isEmpty;
|
|
1240
|
-
if (isEmpty) {
|
|
1241
|
-
this.element.style.backgroundColor = this.getColor(EDITOR_GROUP_EMPTY_BACKGROUND) || '';
|
|
1242
|
-
}
|
|
1243
|
-
else {
|
|
1244
|
-
this.element.style.backgroundColor = '';
|
|
1245
|
-
}
|
|
1246
|
-
const borderColor = this.getColor(EDITOR_GROUP_HEADER_BORDER) || this.getColor(contrastBorder);
|
|
1247
|
-
if (!isEmpty && borderColor) {
|
|
1248
|
-
this.titleContainer.classList.add('title-border-bottom');
|
|
1249
|
-
this.titleContainer.style.setProperty('--title-border-bottom-color', borderColor);
|
|
1250
|
-
}
|
|
1251
|
-
else {
|
|
1252
|
-
this.titleContainer.classList.remove('title-border-bottom');
|
|
1253
|
-
this.titleContainer.style.removeProperty('--title-border-bottom-color');
|
|
1254
|
-
}
|
|
1255
|
-
const { showTabs } = this.groupsView.partOptions;
|
|
1256
|
-
this.titleContainer.style.backgroundColor = this.getColor(showTabs === 'multiple' ? EDITOR_GROUP_HEADER_TABS_BACKGROUND : EDITOR_GROUP_HEADER_NO_TABS_BACKGROUND) || '';
|
|
1257
|
-
this.editorContainer.style.backgroundColor = this.getColor(editorBackground) || '';
|
|
1258
|
-
}
|
|
1259
|
-
get minimumWidth() { return this.editorPane.minimumWidth; }
|
|
1260
|
-
get minimumHeight() { return this.editorPane.minimumHeight; }
|
|
1261
|
-
get maximumWidth() { return this.editorPane.maximumWidth; }
|
|
1262
|
-
get maximumHeight() { return this.editorPane.maximumHeight; }
|
|
1263
|
-
get proportionalLayout() {
|
|
1264
|
-
if (!this.lastLayout) {
|
|
1265
|
-
return true;
|
|
1266
|
-
}
|
|
1267
|
-
return !(this.lastLayout.width === this.minimumWidth || this.lastLayout.height === this.minimumHeight);
|
|
1268
|
-
}
|
|
1269
|
-
layout(width, height, top, left) {
|
|
1270
|
-
this.lastLayout = { width, height, top, left };
|
|
1271
|
-
this.element.classList.toggle('max-height-478px', height <= 478);
|
|
1272
|
-
const titleControlSize = this.titleControl.layout({
|
|
1273
|
-
container: ( new Dimension(width, height)),
|
|
1274
|
-
available: ( new Dimension(width, height - this.editorPane.minimumHeight))
|
|
1275
|
-
});
|
|
1276
|
-
this.progressBar.getContainer().style.top = `${Math.max(this.titleHeight.offset - 2, 0)}px`;
|
|
1277
|
-
const editorHeight = Math.max(0, height - titleControlSize.height);
|
|
1278
|
-
this.editorContainer.style.height = `${editorHeight}px`;
|
|
1279
|
-
this.editorPane.layout({ width, height: editorHeight, top: top + titleControlSize.height, left });
|
|
1280
|
-
}
|
|
1281
|
-
relayout() {
|
|
1282
|
-
if (this.lastLayout) {
|
|
1283
|
-
const { width, height, top, left } = this.lastLayout;
|
|
1284
|
-
this.layout(width, height, top, left);
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
setBoundarySashes(sashes) {
|
|
1288
|
-
this.editorPane.setBoundarySashes(sashes);
|
|
1289
|
-
}
|
|
1290
|
-
toJSON() {
|
|
1291
|
-
return this.model.serialize();
|
|
1292
|
-
}
|
|
1293
|
-
dispose() {
|
|
1294
|
-
this._disposed = true;
|
|
1295
|
-
this._onWillDispose.fire();
|
|
1296
|
-
super.dispose();
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
|
-
EditorGroupView = EditorGroupView_1 = ( __decorate([
|
|
1300
|
-
( __param(5, IInstantiationService)),
|
|
1301
|
-
( __param(6, IContextKeyService)),
|
|
1302
|
-
( __param(7, IThemeService)),
|
|
1303
|
-
( __param(8, ITelemetryService)),
|
|
1304
|
-
( __param(9, IKeybindingService)),
|
|
1305
|
-
( __param(10, IMenuService)),
|
|
1306
|
-
( __param(11, IContextMenuService)),
|
|
1307
|
-
( __param(12, IFileDialogService)),
|
|
1308
|
-
( __param(13, IEditorService)),
|
|
1309
|
-
( __param(14, IFilesConfigurationService)),
|
|
1310
|
-
( __param(15, IUriIdentityService)),
|
|
1311
|
-
( __param(16, ILogService)),
|
|
1312
|
-
( __param(17, IEditorResolverService))
|
|
1313
|
-
], EditorGroupView));
|
|
1314
|
-
|
|
1315
|
-
export { EditorGroupView };
|