@codingame/monaco-vscode-a17e9d37-b6c1-5556-8402-5db73960fae3-common 20.0.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/empty.js +1 -0
- package/package.json +44 -0
- package/vscode/src/vs/base/common/fuzzyScorer.d.ts +41 -0
- package/vscode/src/vs/base/common/fuzzyScorer.js +487 -0
- package/vscode/src/vs/platform/quickinput/browser/pickerQuickAccess.d.ts +42 -0
- package/vscode/src/vs/platform/quickinput/browser/pickerQuickAccess.js +228 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorCommandsContext.d.ts +13 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorCommandsContext.js +137 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorWithViewState.d.ts +39 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorWithViewState.js +139 -0
- package/vscode/src/vs/workbench/browser/parts/editor/textEditor.d.ts +84 -0
- package/vscode/src/vs/workbench/browser/parts/editor/textEditor.js +254 -0
- package/vscode/src/vs/workbench/services/editor/common/editorGroupColumn.d.ts +8 -0
- package/vscode/src/vs/workbench/services/editor/common/editorGroupColumn.js +26 -0
@@ -0,0 +1,228 @@
|
|
1
|
+
|
2
|
+
import { timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
3
|
+
import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
4
|
+
import { Disposable, DisposableStore, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
5
|
+
import { isFunction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
6
|
+
|
7
|
+
var TriggerAction;
|
8
|
+
(function (TriggerAction) {
|
9
|
+
TriggerAction[TriggerAction["NO_ACTION"] = 0] = "NO_ACTION";
|
10
|
+
TriggerAction[TriggerAction["CLOSE_PICKER"] = 1] = "CLOSE_PICKER";
|
11
|
+
TriggerAction[TriggerAction["REFRESH_PICKER"] = 2] = "REFRESH_PICKER";
|
12
|
+
TriggerAction[TriggerAction["REMOVE_ITEM"] = 3] = "REMOVE_ITEM";
|
13
|
+
})(TriggerAction || (TriggerAction = {}));
|
14
|
+
function isPicksWithActive(obj) {
|
15
|
+
const candidate = obj;
|
16
|
+
return Array.isArray(candidate.items);
|
17
|
+
}
|
18
|
+
function isFastAndSlowPicks(obj) {
|
19
|
+
const candidate = obj;
|
20
|
+
return !!candidate.picks && candidate.additionalPicks instanceof Promise;
|
21
|
+
}
|
22
|
+
class PickerQuickAccessProvider extends Disposable {
|
23
|
+
constructor(prefix, options) {
|
24
|
+
super();
|
25
|
+
this.prefix = prefix;
|
26
|
+
this.options = options;
|
27
|
+
}
|
28
|
+
provide(picker, token, runOptions) {
|
29
|
+
const disposables = ( new DisposableStore());
|
30
|
+
picker.canAcceptInBackground = !!this.options?.canAcceptInBackground;
|
31
|
+
picker.matchOnLabel = picker.matchOnDescription = picker.matchOnDetail = picker.sortByLabel = false;
|
32
|
+
let picksCts = undefined;
|
33
|
+
const picksDisposable = disposables.add(( new MutableDisposable()));
|
34
|
+
const updatePickerItems = async () => {
|
35
|
+
picksCts?.dispose(true);
|
36
|
+
picker.busy = false;
|
37
|
+
const picksDisposables = picksDisposable.value = ( new DisposableStore());
|
38
|
+
picksCts = picksDisposables.add(( new CancellationTokenSource(token)));
|
39
|
+
const picksToken = picksCts.token;
|
40
|
+
let picksFilter = picker.value.substring(this.prefix.length);
|
41
|
+
if (!this.options?.shouldSkipTrimPickFilter) {
|
42
|
+
picksFilter = picksFilter.trim();
|
43
|
+
}
|
44
|
+
const providedPicks = this._getPicks(picksFilter, picksDisposables, picksToken, runOptions);
|
45
|
+
const applyPicks = (picks, skipEmpty) => {
|
46
|
+
let items;
|
47
|
+
let activeItem = undefined;
|
48
|
+
if (isPicksWithActive(picks)) {
|
49
|
+
items = picks.items;
|
50
|
+
activeItem = picks.active;
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
items = picks;
|
54
|
+
}
|
55
|
+
if (items.length === 0) {
|
56
|
+
if (skipEmpty) {
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
if ((picksFilter.length > 0 || picker.hideInput) && this.options?.noResultsPick) {
|
60
|
+
if (isFunction(this.options.noResultsPick)) {
|
61
|
+
items = [this.options.noResultsPick(picksFilter)];
|
62
|
+
}
|
63
|
+
else {
|
64
|
+
items = [this.options.noResultsPick];
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
picker.items = items;
|
69
|
+
if (activeItem) {
|
70
|
+
picker.activeItems = [activeItem];
|
71
|
+
}
|
72
|
+
return true;
|
73
|
+
};
|
74
|
+
const applyFastAndSlowPicks = async (fastAndSlowPicks) => {
|
75
|
+
let fastPicksApplied = false;
|
76
|
+
let slowPicksApplied = false;
|
77
|
+
await Promise.all([
|
78
|
+
(async () => {
|
79
|
+
if (typeof fastAndSlowPicks.mergeDelay === 'number') {
|
80
|
+
await timeout(fastAndSlowPicks.mergeDelay);
|
81
|
+
if (picksToken.isCancellationRequested) {
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
if (!slowPicksApplied) {
|
86
|
+
fastPicksApplied = applyPicks(fastAndSlowPicks.picks, true );
|
87
|
+
}
|
88
|
+
})(),
|
89
|
+
(async () => {
|
90
|
+
picker.busy = true;
|
91
|
+
try {
|
92
|
+
const awaitedAdditionalPicks = await fastAndSlowPicks.additionalPicks;
|
93
|
+
if (picksToken.isCancellationRequested) {
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
let picks;
|
97
|
+
let activePick = undefined;
|
98
|
+
if (isPicksWithActive(fastAndSlowPicks.picks)) {
|
99
|
+
picks = fastAndSlowPicks.picks.items;
|
100
|
+
activePick = fastAndSlowPicks.picks.active;
|
101
|
+
}
|
102
|
+
else {
|
103
|
+
picks = fastAndSlowPicks.picks;
|
104
|
+
}
|
105
|
+
let additionalPicks;
|
106
|
+
let additionalActivePick = undefined;
|
107
|
+
if (isPicksWithActive(awaitedAdditionalPicks)) {
|
108
|
+
additionalPicks = awaitedAdditionalPicks.items;
|
109
|
+
additionalActivePick = awaitedAdditionalPicks.active;
|
110
|
+
}
|
111
|
+
else {
|
112
|
+
additionalPicks = awaitedAdditionalPicks;
|
113
|
+
}
|
114
|
+
if (additionalPicks.length > 0 || !fastPicksApplied) {
|
115
|
+
let fallbackActivePick = undefined;
|
116
|
+
if (!activePick && !additionalActivePick) {
|
117
|
+
const fallbackActivePickCandidate = picker.activeItems[0];
|
118
|
+
if (fallbackActivePickCandidate && picks.indexOf(fallbackActivePickCandidate) !== -1) {
|
119
|
+
fallbackActivePick = fallbackActivePickCandidate;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
applyPicks({
|
123
|
+
items: [...picks, ...additionalPicks],
|
124
|
+
active: activePick || additionalActivePick || fallbackActivePick
|
125
|
+
});
|
126
|
+
}
|
127
|
+
}
|
128
|
+
finally {
|
129
|
+
if (!picksToken.isCancellationRequested) {
|
130
|
+
picker.busy = false;
|
131
|
+
}
|
132
|
+
slowPicksApplied = true;
|
133
|
+
}
|
134
|
+
})()
|
135
|
+
]);
|
136
|
+
};
|
137
|
+
if (providedPicks === null) ;
|
138
|
+
else if (isFastAndSlowPicks(providedPicks)) {
|
139
|
+
await applyFastAndSlowPicks(providedPicks);
|
140
|
+
}
|
141
|
+
else if (!(providedPicks instanceof Promise)) {
|
142
|
+
applyPicks(providedPicks);
|
143
|
+
}
|
144
|
+
else {
|
145
|
+
picker.busy = true;
|
146
|
+
try {
|
147
|
+
const awaitedPicks = await providedPicks;
|
148
|
+
if (picksToken.isCancellationRequested) {
|
149
|
+
return;
|
150
|
+
}
|
151
|
+
if (isFastAndSlowPicks(awaitedPicks)) {
|
152
|
+
await applyFastAndSlowPicks(awaitedPicks);
|
153
|
+
}
|
154
|
+
else {
|
155
|
+
applyPicks(awaitedPicks);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
finally {
|
159
|
+
if (!picksToken.isCancellationRequested) {
|
160
|
+
picker.busy = false;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
};
|
165
|
+
disposables.add(picker.onDidChangeValue(() => updatePickerItems()));
|
166
|
+
updatePickerItems();
|
167
|
+
disposables.add(picker.onDidAccept(event => {
|
168
|
+
if (runOptions?.handleAccept) {
|
169
|
+
if (!event.inBackground) {
|
170
|
+
picker.hide();
|
171
|
+
}
|
172
|
+
runOptions.handleAccept?.(picker.activeItems[0], event.inBackground);
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
const [item] = picker.selectedItems;
|
176
|
+
if (typeof item?.accept === 'function') {
|
177
|
+
if (!event.inBackground) {
|
178
|
+
picker.hide();
|
179
|
+
}
|
180
|
+
item.accept(picker.keyMods, event);
|
181
|
+
}
|
182
|
+
}));
|
183
|
+
const buttonTrigger = async (button, item) => {
|
184
|
+
if (typeof item.trigger !== 'function') {
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
const buttonIndex = item.buttons?.indexOf(button) ?? -1;
|
188
|
+
if (buttonIndex >= 0) {
|
189
|
+
const result = item.trigger(buttonIndex, picker.keyMods);
|
190
|
+
const action = (typeof result === 'number') ? result : await result;
|
191
|
+
if (token.isCancellationRequested) {
|
192
|
+
return;
|
193
|
+
}
|
194
|
+
switch (action) {
|
195
|
+
case TriggerAction.NO_ACTION:
|
196
|
+
break;
|
197
|
+
case TriggerAction.CLOSE_PICKER:
|
198
|
+
picker.hide();
|
199
|
+
break;
|
200
|
+
case TriggerAction.REFRESH_PICKER:
|
201
|
+
updatePickerItems();
|
202
|
+
break;
|
203
|
+
case TriggerAction.REMOVE_ITEM: {
|
204
|
+
const index = picker.items.indexOf(item);
|
205
|
+
if (index !== -1) {
|
206
|
+
const items = picker.items.slice();
|
207
|
+
const removed = items.splice(index, 1);
|
208
|
+
const activeItems = picker.activeItems.filter(activeItem => activeItem !== removed[0]);
|
209
|
+
const keepScrollPositionBefore = picker.keepScrollPosition;
|
210
|
+
picker.keepScrollPosition = true;
|
211
|
+
picker.items = items;
|
212
|
+
if (activeItems) {
|
213
|
+
picker.activeItems = activeItems;
|
214
|
+
}
|
215
|
+
picker.keepScrollPosition = keepScrollPositionBefore;
|
216
|
+
}
|
217
|
+
break;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
};
|
222
|
+
disposables.add(picker.onDidTriggerItemButton(({ button, item }) => buttonTrigger(button, item)));
|
223
|
+
disposables.add(picker.onDidTriggerSeparatorButton(({ button, separator }) => buttonTrigger(button, separator)));
|
224
|
+
return disposables;
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
export { PickerQuickAccessProvider, TriggerAction };
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { IListService } from "@codingame/monaco-vscode-api/vscode/vs/platform/list/browser/listService.service";
|
2
|
+
import { EditorInput } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/editorInput";
|
3
|
+
import { IEditorGroup } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService";
|
4
|
+
import { IEditorGroupsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service";
|
5
|
+
import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
|
6
|
+
export interface IResolvedEditorCommandsContext {
|
7
|
+
readonly groupedEditors: {
|
8
|
+
readonly group: IEditorGroup;
|
9
|
+
readonly editors: EditorInput[];
|
10
|
+
}[];
|
11
|
+
readonly preserveFocus: boolean;
|
12
|
+
}
|
13
|
+
export declare function resolveCommandsContext(commandArgs: unknown[], editorService: IEditorService, editorGroupsService: IEditorGroupsService, listService: IListService): IResolvedEditorCommandsContext;
|
@@ -0,0 +1,137 @@
|
|
1
|
+
|
2
|
+
import { getActiveElement } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
3
|
+
import { List } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/list/listWidget';
|
4
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
5
|
+
import { isEditorCommandsContext, isEditorIdentifier } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
|
6
|
+
import { isEditorGroup } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
7
|
+
|
8
|
+
function resolveCommandsContext(commandArgs, editorService, editorGroupsService, listService) {
|
9
|
+
const commandContext = getCommandsContext(commandArgs, editorService, editorGroupsService, listService);
|
10
|
+
const preserveFocus = commandContext.length ? commandContext[0].preserveFocus || false : false;
|
11
|
+
const resolvedContext = { groupedEditors: [], preserveFocus };
|
12
|
+
for (const editorContext of commandContext) {
|
13
|
+
const groupAndEditor = getEditorAndGroupFromContext(editorContext, editorGroupsService);
|
14
|
+
if (!groupAndEditor) {
|
15
|
+
continue;
|
16
|
+
}
|
17
|
+
const { group, editor } = groupAndEditor;
|
18
|
+
let groupContext = undefined;
|
19
|
+
for (const targetGroupContext of resolvedContext.groupedEditors) {
|
20
|
+
if (targetGroupContext.group.id === group.id) {
|
21
|
+
groupContext = targetGroupContext;
|
22
|
+
break;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
if (!groupContext) {
|
26
|
+
groupContext = { group, editors: [] };
|
27
|
+
resolvedContext.groupedEditors.push(groupContext);
|
28
|
+
}
|
29
|
+
if (editor) {
|
30
|
+
groupContext.editors.push(editor);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
return resolvedContext;
|
34
|
+
}
|
35
|
+
function getCommandsContext(commandArgs, editorService, editorGroupsService, listService) {
|
36
|
+
const list = listService.lastFocusedList;
|
37
|
+
let isListAction = list instanceof List && list.getHTMLElement() === getActiveElement();
|
38
|
+
let editorContext = getEditorContextFromCommandArgs(commandArgs, isListAction, editorService, editorGroupsService, listService);
|
39
|
+
if (!editorContext) {
|
40
|
+
const activeGroup = editorGroupsService.activeGroup;
|
41
|
+
const activeEditor = activeGroup.activeEditor;
|
42
|
+
editorContext = { groupId: activeGroup.id, editorIndex: activeEditor ? activeGroup.getIndexOfEditor(activeEditor) : undefined };
|
43
|
+
isListAction = false;
|
44
|
+
}
|
45
|
+
const multiEditorContext = getMultiSelectContext(editorContext, isListAction, editorService, editorGroupsService, listService);
|
46
|
+
return moveCurrentEditorContextToFront(editorContext, multiEditorContext);
|
47
|
+
}
|
48
|
+
function moveCurrentEditorContextToFront(editorContext, multiEditorContext) {
|
49
|
+
if (multiEditorContext.length <= 1) {
|
50
|
+
return multiEditorContext;
|
51
|
+
}
|
52
|
+
const editorContextIndex = multiEditorContext.findIndex(context => context.groupId === editorContext.groupId &&
|
53
|
+
context.editorIndex === editorContext.editorIndex);
|
54
|
+
if (editorContextIndex !== -1) {
|
55
|
+
multiEditorContext.splice(editorContextIndex, 1);
|
56
|
+
multiEditorContext.unshift(editorContext);
|
57
|
+
}
|
58
|
+
else if (editorContext.editorIndex === undefined) {
|
59
|
+
multiEditorContext.unshift(editorContext);
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
throw ( new Error('Editor context not found in multi editor context'));
|
63
|
+
}
|
64
|
+
return multiEditorContext;
|
65
|
+
}
|
66
|
+
function getEditorContextFromCommandArgs(commandArgs, isListAction, editorService, editorGroupsService, listService) {
|
67
|
+
const filteredArgs = commandArgs.filter(arg => isEditorCommandsContext(arg) || URI.isUri(arg));
|
68
|
+
for (const arg of filteredArgs) {
|
69
|
+
if (isEditorCommandsContext(arg)) {
|
70
|
+
return arg;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
for (const uri of filteredArgs) {
|
74
|
+
const editorIdentifiers = editorService.findEditors(uri);
|
75
|
+
if (editorIdentifiers.length) {
|
76
|
+
const editorIdentifier = editorIdentifiers[0];
|
77
|
+
const group = editorGroupsService.getGroup(editorIdentifier.groupId);
|
78
|
+
return { groupId: editorIdentifier.groupId, editorIndex: group?.getIndexOfEditor(editorIdentifier.editor) };
|
79
|
+
}
|
80
|
+
}
|
81
|
+
if (isListAction) {
|
82
|
+
const list = listService.lastFocusedList;
|
83
|
+
for (const focusedElement of list.getFocusedElements()) {
|
84
|
+
if (isGroupOrEditor(focusedElement)) {
|
85
|
+
return groupOrEditorToEditorContext(focusedElement, undefined, editorGroupsService);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
return undefined;
|
90
|
+
}
|
91
|
+
function getMultiSelectContext(editorContext, isListAction, editorService, editorGroupsService, listService) {
|
92
|
+
if (isListAction) {
|
93
|
+
const list = listService.lastFocusedList;
|
94
|
+
const selection = list.getSelectedElements().filter(isGroupOrEditor);
|
95
|
+
if (selection.length > 1) {
|
96
|
+
return ( selection.map(
|
97
|
+
e => groupOrEditorToEditorContext(e, editorContext.preserveFocus, editorGroupsService)
|
98
|
+
));
|
99
|
+
}
|
100
|
+
if (selection.length === 0) {
|
101
|
+
return getMultiSelectContext(editorContext, false, editorService, editorGroupsService, listService);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
const group = editorGroupsService.getGroup(editorContext.groupId);
|
106
|
+
const editor = editorContext.editorIndex !== undefined ? group?.getEditorByIndex(editorContext.editorIndex) : group?.activeEditor;
|
107
|
+
if (group && editor && group.isSelected(editor)) {
|
108
|
+
return ( group.selectedEditors.map(
|
109
|
+
editor => groupOrEditorToEditorContext({ editor, groupId: group.id }, editorContext.preserveFocus, editorGroupsService)
|
110
|
+
));
|
111
|
+
}
|
112
|
+
}
|
113
|
+
return [editorContext];
|
114
|
+
}
|
115
|
+
function groupOrEditorToEditorContext(element, preserveFocus, editorGroupsService) {
|
116
|
+
if (isEditorGroup(element)) {
|
117
|
+
return { groupId: element.id, editorIndex: undefined, preserveFocus };
|
118
|
+
}
|
119
|
+
const group = editorGroupsService.getGroup(element.groupId);
|
120
|
+
return { groupId: element.groupId, editorIndex: group ? group.getIndexOfEditor(element.editor) : -1, preserveFocus };
|
121
|
+
}
|
122
|
+
function isGroupOrEditor(element) {
|
123
|
+
return isEditorGroup(element) || isEditorIdentifier(element);
|
124
|
+
}
|
125
|
+
function getEditorAndGroupFromContext(commandContext, editorGroupsService) {
|
126
|
+
const group = editorGroupsService.getGroup(commandContext.groupId);
|
127
|
+
if (!group) {
|
128
|
+
return undefined;
|
129
|
+
}
|
130
|
+
if (commandContext.editorIndex === undefined) {
|
131
|
+
return { group, editor: undefined };
|
132
|
+
}
|
133
|
+
const editor = group.getEditorByIndex(commandContext.editorIndex);
|
134
|
+
return { group, editor };
|
135
|
+
}
|
136
|
+
|
137
|
+
export { resolveCommandsContext };
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
2
|
+
import { IEditorOpenContext } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor";
|
3
|
+
import { EditorPane } from "@codingame/monaco-vscode-60014c9d-b815-501d-83a9-4b08725c2ec2-common/vscode/vs/workbench/browser/parts/editor/editorPane";
|
4
|
+
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
5
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
6
|
+
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
7
|
+
import { IThemeService } from "@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service";
|
8
|
+
import { ITextResourceConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/textResourceConfiguration.service";
|
9
|
+
import { IEditorGroup } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService";
|
10
|
+
import { IEditorGroupsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service";
|
11
|
+
import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
|
12
|
+
import { IExtUri } from "@codingame/monaco-vscode-api/vscode/vs/base/common/resources";
|
13
|
+
import { EditorInput } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/editorInput";
|
14
|
+
export declare abstract class AbstractEditorWithViewState<T extends object> extends EditorPane {
|
15
|
+
protected readonly instantiationService: IInstantiationService;
|
16
|
+
protected readonly textResourceConfigurationService: ITextResourceConfigurationService;
|
17
|
+
protected readonly editorService: IEditorService;
|
18
|
+
protected readonly editorGroupService: IEditorGroupsService;
|
19
|
+
private viewState;
|
20
|
+
private readonly groupListener;
|
21
|
+
private editorViewStateDisposables;
|
22
|
+
constructor(id: string, group: IEditorGroup, viewStateStorageKey: string, telemetryService: ITelemetryService, instantiationService: IInstantiationService, storageService: IStorageService, textResourceConfigurationService: ITextResourceConfigurationService, themeService: IThemeService, editorService: IEditorService, editorGroupService: IEditorGroupsService);
|
23
|
+
protected setEditorVisible(visible: boolean): void;
|
24
|
+
private onWillCloseEditor;
|
25
|
+
clearInput(): void;
|
26
|
+
protected saveState(): void;
|
27
|
+
private updateEditorViewState;
|
28
|
+
private shouldRestoreEditorViewState;
|
29
|
+
getViewState(): T | undefined;
|
30
|
+
private saveEditorViewState;
|
31
|
+
protected loadEditorViewState(input: EditorInput | undefined, context?: IEditorOpenContext): T | undefined;
|
32
|
+
protected moveEditorViewState(source: URI, target: URI, comparer: IExtUri): void;
|
33
|
+
protected clearEditorViewState(resource: URI, group?: IEditorGroup): void;
|
34
|
+
dispose(): void;
|
35
|
+
protected abstract computeEditorViewState(resource: URI): T | undefined;
|
36
|
+
protected abstract tracksEditorViewState(input: EditorInput): boolean;
|
37
|
+
protected tracksDisposedEditorViewState(): boolean;
|
38
|
+
protected abstract toEditorViewStateResource(input: EditorInput): URI | undefined;
|
39
|
+
}
|
@@ -0,0 +1,139 @@
|
|
1
|
+
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
3
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
4
|
+
import { EditorResourceAccessor, SideBySideEditor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
|
5
|
+
import { EditorPane } from '@codingame/monaco-vscode-60014c9d-b815-501d-83a9-4b08725c2ec2-common/vscode/vs/workbench/browser/parts/editor/editorPane';
|
6
|
+
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
7
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
8
|
+
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
9
|
+
import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
|
10
|
+
import { ITextResourceConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/textResourceConfiguration.service';
|
11
|
+
import { IEditorGroupsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
|
12
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
13
|
+
import { MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
14
|
+
|
15
|
+
let AbstractEditorWithViewState = class AbstractEditorWithViewState extends EditorPane {
|
16
|
+
constructor(id, group, viewStateStorageKey, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorService, editorGroupService) {
|
17
|
+
super(id, group, telemetryService, themeService, storageService);
|
18
|
+
this.instantiationService = instantiationService;
|
19
|
+
this.textResourceConfigurationService = textResourceConfigurationService;
|
20
|
+
this.editorService = editorService;
|
21
|
+
this.editorGroupService = editorGroupService;
|
22
|
+
this.groupListener = this._register(( new MutableDisposable()));
|
23
|
+
this.viewState = this.getEditorMemento(editorGroupService, textResourceConfigurationService, viewStateStorageKey, 100);
|
24
|
+
}
|
25
|
+
setEditorVisible(visible) {
|
26
|
+
this.groupListener.value = this.group.onWillCloseEditor(e => this.onWillCloseEditor(e));
|
27
|
+
super.setEditorVisible(visible);
|
28
|
+
}
|
29
|
+
onWillCloseEditor(e) {
|
30
|
+
const editor = e.editor;
|
31
|
+
if (editor === this.input) {
|
32
|
+
this.updateEditorViewState(editor);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
clearInput() {
|
36
|
+
this.updateEditorViewState(this.input);
|
37
|
+
super.clearInput();
|
38
|
+
}
|
39
|
+
saveState() {
|
40
|
+
this.updateEditorViewState(this.input);
|
41
|
+
super.saveState();
|
42
|
+
}
|
43
|
+
updateEditorViewState(input) {
|
44
|
+
if (!input || !this.tracksEditorViewState(input)) {
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
const resource = this.toEditorViewStateResource(input);
|
48
|
+
if (!resource) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
if (!this.tracksDisposedEditorViewState()) {
|
52
|
+
if (!this.editorViewStateDisposables) {
|
53
|
+
this.editorViewStateDisposables = ( new Map());
|
54
|
+
}
|
55
|
+
if (!( this.editorViewStateDisposables.has(input))) {
|
56
|
+
this.editorViewStateDisposables.set(input, Event.once(input.onWillDispose)(() => {
|
57
|
+
this.clearEditorViewState(resource, this.group);
|
58
|
+
this.editorViewStateDisposables?.delete(input);
|
59
|
+
}));
|
60
|
+
}
|
61
|
+
}
|
62
|
+
if ((input.isDisposed() && !this.tracksDisposedEditorViewState()) ||
|
63
|
+
(!this.shouldRestoreEditorViewState(input) && !this.group.contains(input))) {
|
64
|
+
this.clearEditorViewState(resource, this.group);
|
65
|
+
}
|
66
|
+
else if (!input.isDisposed()) {
|
67
|
+
this.saveEditorViewState(resource);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
shouldRestoreEditorViewState(input, context) {
|
71
|
+
if (context?.newInGroup) {
|
72
|
+
return this.textResourceConfigurationService.getValue(EditorResourceAccessor.getOriginalUri(input, { supportSideBySide: SideBySideEditor.PRIMARY }), 'workbench.editor.restoreViewState') === false ? false : true ;
|
73
|
+
}
|
74
|
+
return true;
|
75
|
+
}
|
76
|
+
getViewState() {
|
77
|
+
const input = this.input;
|
78
|
+
if (!input || !this.tracksEditorViewState(input)) {
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
const resource = this.toEditorViewStateResource(input);
|
82
|
+
if (!resource) {
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
return this.computeEditorViewState(resource);
|
86
|
+
}
|
87
|
+
saveEditorViewState(resource) {
|
88
|
+
const editorViewState = this.computeEditorViewState(resource);
|
89
|
+
if (!editorViewState) {
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
this.viewState.saveEditorState(this.group, resource, editorViewState);
|
93
|
+
}
|
94
|
+
loadEditorViewState(input, context) {
|
95
|
+
if (!input) {
|
96
|
+
return undefined;
|
97
|
+
}
|
98
|
+
if (!this.tracksEditorViewState(input)) {
|
99
|
+
return undefined;
|
100
|
+
}
|
101
|
+
if (!this.shouldRestoreEditorViewState(input, context)) {
|
102
|
+
return undefined;
|
103
|
+
}
|
104
|
+
const resource = this.toEditorViewStateResource(input);
|
105
|
+
if (!resource) {
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
return this.viewState.loadEditorState(this.group, resource);
|
109
|
+
}
|
110
|
+
moveEditorViewState(source, target, comparer) {
|
111
|
+
return this.viewState.moveEditorState(source, target, comparer);
|
112
|
+
}
|
113
|
+
clearEditorViewState(resource, group) {
|
114
|
+
this.viewState.clearEditorState(resource, group);
|
115
|
+
}
|
116
|
+
dispose() {
|
117
|
+
super.dispose();
|
118
|
+
if (this.editorViewStateDisposables) {
|
119
|
+
for (const [, disposables] of this.editorViewStateDisposables) {
|
120
|
+
disposables.dispose();
|
121
|
+
}
|
122
|
+
this.editorViewStateDisposables = undefined;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
tracksDisposedEditorViewState() {
|
126
|
+
return false;
|
127
|
+
}
|
128
|
+
};
|
129
|
+
AbstractEditorWithViewState = ( __decorate([
|
130
|
+
( __param(3, ITelemetryService)),
|
131
|
+
( __param(4, IInstantiationService)),
|
132
|
+
( __param(5, IStorageService)),
|
133
|
+
( __param(6, ITextResourceConfigurationService)),
|
134
|
+
( __param(7, IThemeService)),
|
135
|
+
( __param(8, IEditorService)),
|
136
|
+
( __param(9, IEditorGroupsService))
|
137
|
+
], AbstractEditorWithViewState));
|
138
|
+
|
139
|
+
export { AbstractEditorWithViewState };
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
2
|
+
import { Emitter, Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
3
|
+
import { ICodeEditor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser";
|
4
|
+
import { IEditorOpenContext, IEditorPaneSelection, EditorPaneSelectionCompareResult, IEditorPaneWithSelection, IEditorPaneSelectionChangeEvent, IEditorPaneScrollPosition, IEditorPaneWithScrolling } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor";
|
5
|
+
import { EditorInput } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/editorInput";
|
6
|
+
import { AbstractEditorWithViewState } from "./editorWithViewState.js";
|
7
|
+
import { IEditorViewState } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/editorCommon";
|
8
|
+
import { Selection } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/selection";
|
9
|
+
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
10
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
11
|
+
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
12
|
+
import { IThemeService } from "@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service";
|
13
|
+
import { ITextResourceConfigurationChangeEvent } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/textResourceConfiguration";
|
14
|
+
import { ITextResourceConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/textResourceConfiguration.service";
|
15
|
+
import { IEditorOptions as ICodeEditorOptions } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/config/editorOptions";
|
16
|
+
import { IEditorGroup } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService";
|
17
|
+
import { IEditorGroupsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service";
|
18
|
+
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
19
|
+
import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
|
20
|
+
import { IEditorOptions, ITextEditorOptions } from "@codingame/monaco-vscode-api/vscode/vs/platform/editor/common/editor";
|
21
|
+
import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
|
22
|
+
import { IMarkdownString } from "@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent";
|
23
|
+
export interface IEditorConfiguration {
|
24
|
+
editor: object;
|
25
|
+
diffEditor: object;
|
26
|
+
accessibility?: {
|
27
|
+
verbosity?: {
|
28
|
+
diffEditor?: boolean;
|
29
|
+
};
|
30
|
+
};
|
31
|
+
problems?: {
|
32
|
+
visibility?: boolean;
|
33
|
+
};
|
34
|
+
}
|
35
|
+
export declare abstract class AbstractTextEditor<T extends IEditorViewState> extends AbstractEditorWithViewState<T> implements IEditorPaneWithSelection, IEditorPaneWithScrolling {
|
36
|
+
protected readonly fileService: IFileService;
|
37
|
+
private static readonly VIEW_STATE_PREFERENCE_KEY;
|
38
|
+
protected readonly _onDidChangeSelection: Emitter<IEditorPaneSelectionChangeEvent>;
|
39
|
+
readonly onDidChangeSelection: Event<IEditorPaneSelectionChangeEvent>;
|
40
|
+
protected readonly _onDidChangeScroll: Emitter<void>;
|
41
|
+
readonly onDidChangeScroll: Event<void>;
|
42
|
+
private editorContainer;
|
43
|
+
private hasPendingConfigurationChange;
|
44
|
+
private lastAppliedEditorOptions?;
|
45
|
+
private readonly inputListener;
|
46
|
+
constructor(id: string, group: IEditorGroup, telemetryService: ITelemetryService, instantiationService: IInstantiationService, storageService: IStorageService, textResourceConfigurationService: ITextResourceConfigurationService, themeService: IThemeService, editorService: IEditorService, editorGroupService: IEditorGroupsService, fileService: IFileService);
|
47
|
+
private handleConfigurationChangeEvent;
|
48
|
+
protected shouldHandleConfigurationChangeEvent(e: ITextResourceConfigurationChangeEvent, resource: URI | undefined): boolean;
|
49
|
+
private consumePendingConfigurationChangeEvent;
|
50
|
+
protected computeConfiguration(configuration: IEditorConfiguration): ICodeEditorOptions;
|
51
|
+
protected computeAriaLabel(): string;
|
52
|
+
private onDidChangeFileSystemProvider;
|
53
|
+
private onDidChangeInputCapabilities;
|
54
|
+
protected updateReadonly(input: EditorInput): void;
|
55
|
+
protected getReadonlyConfiguration(isReadonly: boolean | IMarkdownString | undefined): {
|
56
|
+
readOnly: boolean;
|
57
|
+
readOnlyMessage: IMarkdownString | undefined;
|
58
|
+
};
|
59
|
+
protected getConfigurationOverrides(configuration: IEditorConfiguration): ICodeEditorOptions;
|
60
|
+
protected createEditor(parent: HTMLElement): void;
|
61
|
+
private registerCodeEditorListeners;
|
62
|
+
private toEditorPaneSelectionChangeReason;
|
63
|
+
getSelection(): IEditorPaneSelection | undefined;
|
64
|
+
protected abstract createEditorControl(parent: HTMLElement, initialOptions: ICodeEditorOptions): void;
|
65
|
+
protected abstract updateEditorControlOptions(options: ICodeEditorOptions): void;
|
66
|
+
protected abstract getMainControl(): ICodeEditor | undefined;
|
67
|
+
setInput(input: EditorInput, options: ITextEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void>;
|
68
|
+
clearInput(): void;
|
69
|
+
getScrollPosition(): IEditorPaneScrollPosition;
|
70
|
+
setScrollPosition(scrollPosition: IEditorPaneScrollPosition): void;
|
71
|
+
protected setEditorVisible(visible: boolean): void;
|
72
|
+
protected toEditorViewStateResource(input: EditorInput): URI | undefined;
|
73
|
+
private updateEditorConfiguration;
|
74
|
+
private getActiveResource;
|
75
|
+
dispose(): void;
|
76
|
+
}
|
77
|
+
export declare class TextEditorPaneSelection implements IEditorPaneSelection {
|
78
|
+
private readonly textSelection;
|
79
|
+
private static readonly TEXT_EDITOR_SELECTION_THRESHOLD;
|
80
|
+
constructor(textSelection: Selection);
|
81
|
+
compare(other: IEditorPaneSelection): EditorPaneSelectionCompareResult;
|
82
|
+
restore(options: IEditorOptions): ITextEditorOptions;
|
83
|
+
log(): string;
|
84
|
+
}
|