@codingame/monaco-vscode-api 1.76.1 → 1.76.3-next.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/README.md +2 -1
- package/dist/api.js +3 -860
- package/dist/{extHost.js → api2.js} +16555 -13467
- package/dist/async.js +107 -2
- package/dist/audioCue.js +105 -103
- package/dist/button.js +1 -1
- package/dist/cancellation.js +3 -0
- package/dist/configuration.js +7 -344
- package/dist/configuration2.js +339 -0
- package/dist/configurationRegistry.js +441 -0
- package/dist/contextkeys.js +211 -0
- package/dist/debug.d.ts +22 -0
- package/dist/debug.js +15842 -0
- package/dist/dialogs.js +855 -9
- package/dist/extensionResourceLoader.js +96 -0
- package/dist/extensions.d.ts +491 -0
- package/dist/extensions.js +70 -0
- package/dist/{tools.js → extensionsRegistry.js} +2 -30
- package/dist/files.js +1407 -334
- package/dist/iconv.js +43 -0
- package/dist/injection.js +1 -1
- package/dist/jschardet.js +7 -0
- package/dist/keybindings.d.ts +1 -485
- package/dist/keybindings.js +666 -679
- package/dist/labels.js +14 -0
- package/dist/languageConfiguration.d.ts +1 -2
- package/dist/languageConfiguration.js +9 -16
- package/dist/languageService.js +112 -8
- package/dist/languages.d.ts +1 -473
- package/dist/languages.js +2 -12
- package/dist/layout.js +4 -3
- package/dist/layoutService.js +1 -1
- package/dist/missing-services.js +4710 -74
- package/dist/modelEditor.d.ts +324 -2
- package/dist/modelEditor.js +15 -228
- package/dist/monaco.js +7 -72
- package/dist/notifications.js +75 -232
- package/dist/polyfill.js +10715 -2459
- package/dist/resources.js +197 -0
- package/dist/services.d.ts +924 -3
- package/dist/services.js +1 -2
- package/dist/services2.js +2436 -18
- package/dist/snippets.d.ts +1 -473
- package/dist/snippets.js +8 -867
- package/dist/snippetsService.js +868 -0
- package/dist/textFileEditorModel.js +2985 -0
- package/dist/textmate.d.ts +3 -475
- package/dist/textmate.js +19 -29
- package/dist/theme.d.ts +1 -3
- package/dist/theme.js +24 -70
- package/dist/tokenClassification.d.ts +1 -475
- package/dist/tokenClassification.js +11 -37
- package/dist/tokenClassificationRegistry.js +8 -4
- package/dist/variableResolver.js +1711 -0
- package/dist/workbenchThemeService.js +1 -1
- package/dist/workspaceContext.js +1 -3
- package/package.json +27 -12
- package/dist/contextkey.js +0 -419
- package/dist/dialog.web.contribution.js +0 -945
package/dist/modelEditor.d.ts
CHANGED
|
@@ -1,5 +1,279 @@
|
|
|
1
1
|
import * as monaco from 'monaco-editor';
|
|
2
|
+
import * as vscode from 'vscode';
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* An object that performs a cleanup operation when `.dispose()` is called.
|
|
6
|
+
*
|
|
7
|
+
* Some examples of how disposables are used:
|
|
8
|
+
*
|
|
9
|
+
* - An event listener that removes itself when `.dispose()` is called.
|
|
10
|
+
* - A resource such as a file system watcher that cleans up the resource when `.dispose()` is called.
|
|
11
|
+
* - The return value from registering a provider. When `.dispose()` is called, the provider is unregistered.
|
|
12
|
+
*/
|
|
13
|
+
interface IDisposable {
|
|
14
|
+
dispose(): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Manages a collection of disposable values.
|
|
18
|
+
*
|
|
19
|
+
* This is the preferred way to manage multiple disposables. A `DisposableStore` is safer to work with than an
|
|
20
|
+
* `IDisposable[]` as it considers edge cases, such as registering the same value multiple times or adding an item to a
|
|
21
|
+
* store that has already been disposed of.
|
|
22
|
+
*/
|
|
23
|
+
declare class DisposableStore implements IDisposable {
|
|
24
|
+
static DISABLE_DISPOSED_WARNING: boolean;
|
|
25
|
+
private readonly _toDispose;
|
|
26
|
+
private _isDisposed;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Dispose of all registered disposables and mark this object as disposed.
|
|
30
|
+
*
|
|
31
|
+
* Any future disposables added to this object will be disposed of on `add`.
|
|
32
|
+
*/
|
|
33
|
+
dispose(): void;
|
|
34
|
+
/**
|
|
35
|
+
* @return `true` if this object has been disposed of.
|
|
36
|
+
*/
|
|
37
|
+
get isDisposed(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Dispose of all registered disposables but do not mark this object as disposed.
|
|
40
|
+
*/
|
|
41
|
+
clear(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Add a new {@link IDisposable disposable} to the collection.
|
|
44
|
+
*/
|
|
45
|
+
add<T extends IDisposable>(o: T): T;
|
|
46
|
+
}
|
|
47
|
+
interface IReference<T> extends IDisposable {
|
|
48
|
+
readonly object: T;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface IObservable<T, TChange = void> {
|
|
52
|
+
readonly TChange: TChange;
|
|
53
|
+
/**
|
|
54
|
+
* Reads the current value.
|
|
55
|
+
*
|
|
56
|
+
* Must not be called from {@link IObserver.handleChange}.
|
|
57
|
+
*/
|
|
58
|
+
get(): T;
|
|
59
|
+
/**
|
|
60
|
+
* Adds an observer.
|
|
61
|
+
*/
|
|
62
|
+
addObserver(observer: IObserver): void;
|
|
63
|
+
removeObserver(observer: IObserver): void;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribes the reader to this observable and returns the current value of this observable.
|
|
66
|
+
*/
|
|
67
|
+
read(reader: IReader): T;
|
|
68
|
+
map<TNew>(fn: (value: T) => TNew): IObservable<TNew>;
|
|
69
|
+
readonly debugName: string;
|
|
70
|
+
}
|
|
71
|
+
interface IReader {
|
|
72
|
+
/**
|
|
73
|
+
* Reports an observable that was read.
|
|
74
|
+
*
|
|
75
|
+
* Is called by {@link IObservable.read}.
|
|
76
|
+
*/
|
|
77
|
+
subscribeTo<T>(observable: IObservable<T, any>): void;
|
|
78
|
+
}
|
|
79
|
+
interface IObserver {
|
|
80
|
+
/**
|
|
81
|
+
* Indicates that an update operation is about to begin.
|
|
82
|
+
*
|
|
83
|
+
* During an update, invariants might not hold for subscribed observables and
|
|
84
|
+
* change events might be delayed.
|
|
85
|
+
* However, all changes must be reported before all update operations are over.
|
|
86
|
+
*/
|
|
87
|
+
beginUpdate<T>(observable: IObservable<T>): void;
|
|
88
|
+
/**
|
|
89
|
+
* Is called by a subscribed observable immediately after it notices a change.
|
|
90
|
+
*
|
|
91
|
+
* When {@link IObservable.get} returns and no change has been reported,
|
|
92
|
+
* there has been no change for that observable.
|
|
93
|
+
*
|
|
94
|
+
* Implementations must not call into other observables!
|
|
95
|
+
* The change should be processed when {@link IObserver.endUpdate} is called.
|
|
96
|
+
*/
|
|
97
|
+
handleChange<T, TChange>(observable: IObservable<T, TChange>, change: TChange): void;
|
|
98
|
+
/**
|
|
99
|
+
* Indicates that an update operation has completed.
|
|
100
|
+
*/
|
|
101
|
+
endUpdate<T>(observable: IObservable<T>): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Can be passed into the Delayed to defer using a microtask
|
|
106
|
+
* */
|
|
107
|
+
declare const MicrotaskDelay: unique symbol;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* An event with zero or one parameters that can be subscribed to. The event is a function itself.
|
|
111
|
+
*/
|
|
112
|
+
type Event<T> = vscode.Event<T>
|
|
113
|
+
declare namespace Event {
|
|
114
|
+
const None: Event<any>;
|
|
115
|
+
/**
|
|
116
|
+
* Given an event, returns another event which debounces calls and defers the listeners to a later task via a shared
|
|
117
|
+
* `setTimeout`. The event is converted into a signal (`Event<void>`) to avoid additional object creation as a
|
|
118
|
+
* result of merging events and to try prevent race conditions that could arise when using related deferred and
|
|
119
|
+
* non-deferred events.
|
|
120
|
+
*
|
|
121
|
+
* This is useful for deferring non-critical work (eg. general UI updates) to ensure it does not block critical work
|
|
122
|
+
* (eg. latency of keypress to text rendered).
|
|
123
|
+
*
|
|
124
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
125
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
126
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
127
|
+
*
|
|
128
|
+
* @param event The event source for the new event.
|
|
129
|
+
* @param disposable A disposable store to add the new EventEmitter to.
|
|
130
|
+
*/
|
|
131
|
+
function defer(event: Event<unknown>, disposable?: DisposableStore): Event<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Given an event, returns another event which only fires once.
|
|
134
|
+
*
|
|
135
|
+
* @param event The event source for the new event.
|
|
136
|
+
*/
|
|
137
|
+
function once<T>(event: Event<T>): Event<T>;
|
|
138
|
+
/**
|
|
139
|
+
* Maps an event of one type into an event of another type using a mapping function, similar to how
|
|
140
|
+
* `Array.prototype.map` works.
|
|
141
|
+
*
|
|
142
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
143
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
144
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
145
|
+
*
|
|
146
|
+
* @param event The event source for the new event.
|
|
147
|
+
* @param map The mapping function.
|
|
148
|
+
* @param disposable A disposable store to add the new EventEmitter to.
|
|
149
|
+
*/
|
|
150
|
+
function map<I, O>(event: Event<I>, map: (i: I) => O, disposable?: DisposableStore): Event<O>;
|
|
151
|
+
/**
|
|
152
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
153
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
154
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
155
|
+
*/
|
|
156
|
+
function forEach<I>(event: Event<I>, each: (i: I) => void, disposable?: DisposableStore): Event<I>;
|
|
157
|
+
/**
|
|
158
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
159
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
160
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
161
|
+
*/
|
|
162
|
+
function filter<T, U>(event: Event<T | U>, filter: (e: T | U) => e is T, disposable?: DisposableStore): Event<T>;
|
|
163
|
+
function filter<T>(event: Event<T>, filter: (e: T) => boolean, disposable?: DisposableStore): Event<T>;
|
|
164
|
+
function filter<T, R>(event: Event<T | R>, filter: (e: T | R) => e is R, disposable?: DisposableStore): Event<R>;
|
|
165
|
+
/**
|
|
166
|
+
* Given an event, returns the same event but typed as `Event<void>`.
|
|
167
|
+
*/
|
|
168
|
+
function signal<T>(event: Event<T>): Event<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Given a collection of events, returns a single event which emits
|
|
171
|
+
* whenever any of the provided events emit.
|
|
172
|
+
*/
|
|
173
|
+
function any<T>(...events: Event<T>[]): Event<T>;
|
|
174
|
+
function any(...events: Event<any>[]): Event<void>;
|
|
175
|
+
/**
|
|
176
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
177
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
178
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
179
|
+
*/
|
|
180
|
+
function reduce<I, O>(event: Event<I>, merge: (last: O | undefined, event: I) => O, initial?: O, disposable?: DisposableStore): Event<O>;
|
|
181
|
+
/**
|
|
182
|
+
* Given an event, creates a new emitter that event that will debounce events based on {@link delay} and give an
|
|
183
|
+
* array event object of all events that fired.
|
|
184
|
+
*
|
|
185
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
186
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
187
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
188
|
+
*
|
|
189
|
+
* @param event The original event to debounce.
|
|
190
|
+
* @param merge A function that reduces all events into a single event.
|
|
191
|
+
* @param delay The number of milliseconds to debounce.
|
|
192
|
+
* @param leading Whether to fire a leading event without debouncing.
|
|
193
|
+
* @param flushOnListenerRemove Whether to fire all debounced events when a listener is removed. If this is not
|
|
194
|
+
* specified, some events could go missing. Use this if it's important that all events are processed, even if the
|
|
195
|
+
* listener gets disposed before the debounced event fires.
|
|
196
|
+
* @param leakWarningThreshold See {@link EmitterOptions.leakWarningThreshold}.
|
|
197
|
+
* @param disposable A disposable store to register the debounce emitter to.
|
|
198
|
+
*/
|
|
199
|
+
function debounce<T>(event: Event<T>, merge: (last: T | undefined, event: T) => T, delay?: number | typeof MicrotaskDelay, leading?: boolean, flushOnListenerRemove?: boolean, leakWarningThreshold?: number, disposable?: DisposableStore): Event<T>;
|
|
200
|
+
function debounce<I, O>(event: Event<I>, merge: (last: O | undefined, event: I) => O, delay?: number | typeof MicrotaskDelay, leading?: boolean, flushOnListenerRemove?: boolean, leakWarningThreshold?: number, disposable?: DisposableStore): Event<O>;
|
|
201
|
+
/**
|
|
202
|
+
* Debounces an event, firing after some delay (default=0) with an array of all event original objects.
|
|
203
|
+
*
|
|
204
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
205
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
206
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
207
|
+
*/
|
|
208
|
+
function accumulate<T>(event: Event<T>, delay?: number, disposable?: DisposableStore): Event<T[]>;
|
|
209
|
+
/**
|
|
210
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
211
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
212
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
213
|
+
*/
|
|
214
|
+
function latch<T>(event: Event<T>, equals?: (a: T, b: T) => boolean, disposable?: DisposableStore): Event<T>;
|
|
215
|
+
/**
|
|
216
|
+
* Splits an event whose parameter is a union type into 2 separate events for each type in the union.
|
|
217
|
+
*
|
|
218
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
219
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
220
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```
|
|
224
|
+
* const event = new EventEmitter<number | undefined>().event;
|
|
225
|
+
* const [numberEvent, undefinedEvent] = Event.split(event, isUndefined);
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @param event The event source for the new event.
|
|
229
|
+
* @param isT A function that determines what event is of the first type.
|
|
230
|
+
* @param disposable A disposable store to add the new EventEmitter to.
|
|
231
|
+
*/
|
|
232
|
+
function split<T, U>(event: Event<T | U>, isT: (e: T | U) => e is T, disposable?: DisposableStore): [Event<T>, Event<U>];
|
|
233
|
+
/**
|
|
234
|
+
* *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
|
|
235
|
+
* event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
|
|
236
|
+
* returned event causes this utility to leak a listener on the original event.
|
|
237
|
+
*/
|
|
238
|
+
function buffer<T>(event: Event<T>, flushAfterTimeout?: boolean, _buffer?: T[]): Event<T>;
|
|
239
|
+
interface IChainableEvent<T> extends IDisposable {
|
|
240
|
+
event: Event<T>;
|
|
241
|
+
map<O>(fn: (i: T) => O): IChainableEvent<O>;
|
|
242
|
+
forEach(fn: (i: T) => void): IChainableEvent<T>;
|
|
243
|
+
filter(fn: (e: T) => boolean): IChainableEvent<T>;
|
|
244
|
+
filter<R>(fn: (e: T | R) => e is R): IChainableEvent<R>;
|
|
245
|
+
reduce<R>(merge: (last: R | undefined, event: T) => R, initial?: R): IChainableEvent<R>;
|
|
246
|
+
latch(): IChainableEvent<T>;
|
|
247
|
+
debounce(merge: (last: T | undefined, event: T) => T, delay?: number, leading?: boolean, flushOnListenerRemove?: boolean, leakWarningThreshold?: number): IChainableEvent<T>;
|
|
248
|
+
debounce<R>(merge: (last: R | undefined, event: T) => R, delay?: number, leading?: boolean, flushOnListenerRemove?: boolean, leakWarningThreshold?: number): IChainableEvent<R>;
|
|
249
|
+
on(listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[] | DisposableStore): IDisposable;
|
|
250
|
+
once(listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[]): IDisposable;
|
|
251
|
+
}
|
|
252
|
+
function chain<T>(event: Event<T>): IChainableEvent<T>;
|
|
253
|
+
interface NodeEventEmitter {
|
|
254
|
+
on(event: string | symbol, listener: Function): unknown;
|
|
255
|
+
removeListener(event: string | symbol, listener: Function): unknown;
|
|
256
|
+
}
|
|
257
|
+
function fromNodeEventEmitter<T>(emitter: NodeEventEmitter, eventName: string, map?: (...args: any[]) => T): Event<T>;
|
|
258
|
+
interface DOMEventEmitter {
|
|
259
|
+
addEventListener(event: string | symbol, listener: Function): void;
|
|
260
|
+
removeEventListener(event: string | symbol, listener: Function): void;
|
|
261
|
+
}
|
|
262
|
+
function fromDOMEventEmitter<T>(emitter: DOMEventEmitter, eventName: string, map?: (...args: any[]) => T): Event<T>;
|
|
263
|
+
function toPromise<T>(event: Event<T>): Promise<T>;
|
|
264
|
+
function runAndSubscribe<T>(event: Event<T>, handler: (e: T | undefined) => any): IDisposable;
|
|
265
|
+
function runAndSubscribeWithStore<T>(event: Event<T>, handler: (e: T | undefined, disposableStore: DisposableStore) => any): IDisposable;
|
|
266
|
+
function fromObservable<T>(obs: IObservable<T, any>, store?: DisposableStore): Event<T>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Text snapshot that works like an iterator.
|
|
271
|
+
* Will try to return chunks of roughly ~64KB size.
|
|
272
|
+
* Will return null when finished.
|
|
273
|
+
*/
|
|
274
|
+
interface ITextSnapshot {
|
|
275
|
+
read(): string | null;
|
|
276
|
+
}
|
|
3
277
|
/**
|
|
4
278
|
* A model.
|
|
5
279
|
*/
|
|
@@ -10,6 +284,28 @@ type ITextModel = monaco.editor.ITextModel
|
|
|
10
284
|
*/
|
|
11
285
|
type ICodeEditor = monaco.editor.ICodeEditor
|
|
12
286
|
|
|
287
|
+
interface IEditorModel {
|
|
288
|
+
/**
|
|
289
|
+
* Emitted when the model is about to be disposed.
|
|
290
|
+
*/
|
|
291
|
+
readonly onWillDispose: Event<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Resolves the model.
|
|
294
|
+
*/
|
|
295
|
+
resolve(): Promise<void>;
|
|
296
|
+
/**
|
|
297
|
+
* Find out if the editor model was resolved or not.
|
|
298
|
+
*/
|
|
299
|
+
isResolved(): boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Find out if this model has been disposed.
|
|
302
|
+
*/
|
|
303
|
+
isDisposed(): boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Dispose associated resources
|
|
306
|
+
*/
|
|
307
|
+
dispose(): void;
|
|
308
|
+
}
|
|
13
309
|
declare enum EditorActivation {
|
|
14
310
|
/**
|
|
15
311
|
* Activate the editor after it opened. This will automatically restore
|
|
@@ -154,7 +450,33 @@ interface IEditorOptions {
|
|
|
154
450
|
|
|
155
451
|
type IEditorOverrideServices = monaco.editor.IEditorOverrideServices
|
|
156
452
|
|
|
157
|
-
|
|
453
|
+
interface ITextEditorModel extends IEditorModel {
|
|
454
|
+
/**
|
|
455
|
+
* Provides access to the underlying `ITextModel`.
|
|
456
|
+
*/
|
|
457
|
+
readonly textEditorModel: ITextModel | null;
|
|
458
|
+
/**
|
|
459
|
+
* Creates a snapshot of the model's contents.
|
|
460
|
+
*/
|
|
461
|
+
createSnapshot(this: IResolvedTextEditorModel): ITextSnapshot;
|
|
462
|
+
createSnapshot(this: ITextEditorModel): ITextSnapshot | null;
|
|
463
|
+
/**
|
|
464
|
+
* Signals if this model is readonly or not.
|
|
465
|
+
*/
|
|
466
|
+
isReadonly(): boolean;
|
|
467
|
+
/**
|
|
468
|
+
* The language id of the text model if known.
|
|
469
|
+
*/
|
|
470
|
+
getLanguageId(): string | undefined;
|
|
471
|
+
}
|
|
472
|
+
interface IResolvedTextEditorModel extends ITextEditorModel {
|
|
473
|
+
/**
|
|
474
|
+
* Same as ITextEditorModel#textEditorModel, but never null.
|
|
475
|
+
*/
|
|
476
|
+
readonly textEditorModel: ITextModel;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
type OpenEditor = (modelRef: IReference<IResolvedTextEditorModel>, options: IEditorOptions | undefined, sideBySide?: boolean) => Promise<ICodeEditor | undefined>;
|
|
158
480
|
declare function getServiceOverride(openEditor: OpenEditor): IEditorOverrideServices;
|
|
159
481
|
|
|
160
|
-
export { IEditorOptions, OpenEditor, getServiceOverride as default };
|
|
482
|
+
export { IEditorOptions, IReference, IResolvedTextEditorModel, OpenEditor, getServiceOverride as default };
|
package/dist/modelEditor.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { _ as __decorate, a as __param, E as Emitter } from './
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ThrottledDelayer } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
6
|
-
import { PLAINTEXT_LANGUAGE_ID } from 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
|
|
7
|
-
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
8
|
-
import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
|
|
1
|
+
import { I as IEditorService, S as SIDE_GROUP, A as ACTIVE_GROUP, _ as __decorate, a as __param, E as Emitter, n as IFileService, j as IUriIdentityService, H as isPreferredGroup, l as ITextFileService } from './services2.js';
|
|
2
|
+
import { A as AsyncReferenceCollection, g as ReferenceCollection } from './polyfill.js';
|
|
3
|
+
import { u as unsupported, bN as isResourceEditorInput, bO as isEditorInput, bP as ILanguageDetectionService, bQ as isTextEditorViewState } from './missing-services.js';
|
|
4
|
+
import { B as BaseTextEditorModel, T as TextFileEditorModel } from './textFileEditorModel.js';
|
|
9
5
|
import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
|
|
6
|
+
import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
|
|
10
7
|
import { IAccessibilityService } from 'monaco-editor/esm/vs/platform/accessibility/common/accessibility.js';
|
|
11
|
-
import {
|
|
8
|
+
import { Disposable, ImmortalReference, dispose, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
12
9
|
import { MultiModelEditStackElement } from 'monaco-editor/esm/vs/editor/common/model/editStack.js';
|
|
13
10
|
import { ITextModelService } from 'monaco-editor/esm/vs/editor/common/services/resolverService.js';
|
|
14
11
|
import { IUndoRedoService } from 'monaco-editor/esm/vs/platform/undoRedo/common/undoRedo.js';
|
|
@@ -29,206 +26,6 @@ function isResolvedTextEditorModel(model) {
|
|
|
29
26
|
const candidate = model;
|
|
30
27
|
return !!candidate.textEditorModel;
|
|
31
28
|
}
|
|
32
|
-
function isResourceEditorInput(editor) {
|
|
33
|
-
if (isEditorInput(editor)) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
const candidate = editor;
|
|
37
|
-
return URI.isUri(candidate?.resource);
|
|
38
|
-
}
|
|
39
|
-
class AbstractEditorInput extends Disposable {
|
|
40
|
-
}
|
|
41
|
-
function isEditorInput(editor) {
|
|
42
|
-
return editor instanceof AbstractEditorInput;
|
|
43
|
-
}
|
|
44
|
-
function isTextEditorViewState(candidate) {
|
|
45
|
-
const viewState = candidate;
|
|
46
|
-
if (!viewState) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
const diffEditorViewState = viewState;
|
|
50
|
-
if (diffEditorViewState.modified) {
|
|
51
|
-
return isTextEditorViewState(diffEditorViewState.modified);
|
|
52
|
-
}
|
|
53
|
-
const codeEditorViewState = viewState;
|
|
54
|
-
return !!(codeEditorViewState.contributionsState && codeEditorViewState.viewState && Array.isArray(codeEditorViewState.cursorState));
|
|
55
|
-
}
|
|
56
|
-
class EditorModel extends Disposable {
|
|
57
|
-
constructor() {
|
|
58
|
-
super(...arguments);
|
|
59
|
-
this._onWillDispose = this._register(( (new Emitter())));
|
|
60
|
-
this.onWillDispose = this._onWillDispose.event;
|
|
61
|
-
this.disposed = false;
|
|
62
|
-
this.resolved = false;
|
|
63
|
-
}
|
|
64
|
-
async resolve() {
|
|
65
|
-
this.resolved = true;
|
|
66
|
-
}
|
|
67
|
-
isResolved() {
|
|
68
|
-
return this.resolved;
|
|
69
|
-
}
|
|
70
|
-
isDisposed() {
|
|
71
|
-
return this.disposed;
|
|
72
|
-
}
|
|
73
|
-
dispose() {
|
|
74
|
-
this.disposed = true;
|
|
75
|
-
this._onWillDispose.fire();
|
|
76
|
-
super.dispose();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
let BaseTextEditorModel = class BaseTextEditorModel extends EditorModel {
|
|
80
|
-
constructor(modelService, languageService, languageDetectionService, accessibilityService, textEditorModelHandle) {
|
|
81
|
-
super();
|
|
82
|
-
this.modelService = modelService;
|
|
83
|
-
this.languageService = languageService;
|
|
84
|
-
this.languageDetectionService = languageDetectionService;
|
|
85
|
-
this.accessibilityService = accessibilityService;
|
|
86
|
-
this.textEditorModelHandle = undefined;
|
|
87
|
-
this.modelDisposeListener = this._register(( (new MutableDisposable())));
|
|
88
|
-
this.autoDetectLanguageThrottler = this._register(( (new ThrottledDelayer(BaseTextEditorModel.AUTO_DETECT_LANGUAGE_THROTTLE_DELAY))));
|
|
89
|
-
this._hasLanguageSetExplicitly = false;
|
|
90
|
-
if (textEditorModelHandle) {
|
|
91
|
-
this.handleExistingModel(textEditorModelHandle);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
handleExistingModel(textEditorModelHandle) {
|
|
95
|
-
const model = this.modelService.getModel(textEditorModelHandle);
|
|
96
|
-
if (!model) {
|
|
97
|
-
throw new Error(`Document with resource ${textEditorModelHandle.toString(true)} does not exist`);
|
|
98
|
-
}
|
|
99
|
-
this.textEditorModelHandle = textEditorModelHandle;
|
|
100
|
-
this.registerModelDisposeListener(model);
|
|
101
|
-
}
|
|
102
|
-
registerModelDisposeListener(model) {
|
|
103
|
-
this.modelDisposeListener.value = model.onWillDispose(() => {
|
|
104
|
-
this.textEditorModelHandle = undefined;
|
|
105
|
-
this.dispose();
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
get textEditorModel() {
|
|
109
|
-
return this.textEditorModelHandle ? this.modelService.getModel(this.textEditorModelHandle) : null;
|
|
110
|
-
}
|
|
111
|
-
isReadonly() {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
get hasLanguageSetExplicitly() { return this._hasLanguageSetExplicitly; }
|
|
115
|
-
setLanguageId(languageId, source) {
|
|
116
|
-
this._hasLanguageSetExplicitly = true;
|
|
117
|
-
this.setLanguageIdInternal(languageId, source);
|
|
118
|
-
}
|
|
119
|
-
setLanguageIdInternal(languageId, source) {
|
|
120
|
-
if (!this.isResolved()) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (!languageId || languageId === this.textEditorModel.getLanguageId()) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
this.modelService.setMode(this.textEditorModel, this.languageService.createById(languageId), source);
|
|
127
|
-
}
|
|
128
|
-
installModelListeners(model) {
|
|
129
|
-
const disposable = this._register(model.onDidChangeLanguage((e) => {
|
|
130
|
-
if (e.source === LanguageDetectionLanguageEventSource) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
this._hasLanguageSetExplicitly = true;
|
|
134
|
-
disposable.dispose();
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
getLanguageId() {
|
|
138
|
-
return this.textEditorModel?.getLanguageId();
|
|
139
|
-
}
|
|
140
|
-
autoDetectLanguage() {
|
|
141
|
-
return this.autoDetectLanguageThrottler.trigger(() => this.doAutoDetectLanguage());
|
|
142
|
-
}
|
|
143
|
-
async doAutoDetectLanguage() {
|
|
144
|
-
if (this.hasLanguageSetExplicitly ||
|
|
145
|
-
!this.textEditorModelHandle ||
|
|
146
|
-
!this.languageDetectionService.isEnabledForLanguage(this.getLanguageId() ?? PLAINTEXT_LANGUAGE_ID)
|
|
147
|
-
) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const lang = await this.languageDetectionService.detectLanguage(this.textEditorModelHandle);
|
|
151
|
-
if (lang && !this.isDisposed()) {
|
|
152
|
-
this.setLanguageIdInternal(lang, LanguageDetectionLanguageEventSource);
|
|
153
|
-
const languageName = this.languageService.getLanguageName(lang);
|
|
154
|
-
if (languageName) {
|
|
155
|
-
this.accessibilityService.alert(( (localize(
|
|
156
|
-
'languageAutoDetected',
|
|
157
|
-
"Language {0} was automatically detected and set as the language mode.",
|
|
158
|
-
languageName
|
|
159
|
-
))));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
createTextEditorModel(value, resource, preferredLanguageId) {
|
|
164
|
-
const firstLineText = this.getFirstLineText(value);
|
|
165
|
-
const languageSelection = this.getOrCreateLanguage(resource, this.languageService, preferredLanguageId, firstLineText);
|
|
166
|
-
return this.doCreateTextEditorModel(value, languageSelection, resource);
|
|
167
|
-
}
|
|
168
|
-
doCreateTextEditorModel(value, languageSelection, resource) {
|
|
169
|
-
let model = resource && this.modelService.getModel(resource);
|
|
170
|
-
if (!model) {
|
|
171
|
-
model = this.modelService.createModel(value, languageSelection, resource);
|
|
172
|
-
this.createdEditorModel = true;
|
|
173
|
-
this.registerModelDisposeListener(model);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
this.updateTextEditorModel(value, languageSelection.languageId);
|
|
177
|
-
}
|
|
178
|
-
this.textEditorModelHandle = model.uri;
|
|
179
|
-
return model;
|
|
180
|
-
}
|
|
181
|
-
getFirstLineText(value) {
|
|
182
|
-
const textBufferFactory = value;
|
|
183
|
-
if (typeof textBufferFactory.getFirstLineText === 'function') {
|
|
184
|
-
return textBufferFactory.getFirstLineText(1000 );
|
|
185
|
-
}
|
|
186
|
-
const textSnapshot = value;
|
|
187
|
-
return textSnapshot.getLineContent(1).substr(0, 1000 );
|
|
188
|
-
}
|
|
189
|
-
getOrCreateLanguage(resource, languageService, preferredLanguage, firstLineText) {
|
|
190
|
-
if (!preferredLanguage || preferredLanguage === PLAINTEXT_LANGUAGE_ID) {
|
|
191
|
-
return languageService.createByFilepathOrFirstLine(withUndefinedAsNull(resource), firstLineText);
|
|
192
|
-
}
|
|
193
|
-
return languageService.createById(preferredLanguage);
|
|
194
|
-
}
|
|
195
|
-
updateTextEditorModel(newValue, preferredLanguageId) {
|
|
196
|
-
if (!this.isResolved()) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
if (newValue) {
|
|
200
|
-
this.modelService.updateModel(this.textEditorModel, newValue);
|
|
201
|
-
}
|
|
202
|
-
if (preferredLanguageId && preferredLanguageId !== PLAINTEXT_LANGUAGE_ID && this.textEditorModel.getLanguageId() !== preferredLanguageId) {
|
|
203
|
-
this.modelService.setMode(this.textEditorModel, this.languageService.createById(preferredLanguageId));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
createSnapshot() {
|
|
207
|
-
if (!this.textEditorModel) {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
return this.textEditorModel.createSnapshot(true );
|
|
211
|
-
}
|
|
212
|
-
isResolved() {
|
|
213
|
-
return !!this.textEditorModelHandle;
|
|
214
|
-
}
|
|
215
|
-
dispose() {
|
|
216
|
-
this.modelDisposeListener.dispose();
|
|
217
|
-
if (this.textEditorModelHandle && this.createdEditorModel) {
|
|
218
|
-
this.modelService.destroyModel(this.textEditorModelHandle);
|
|
219
|
-
}
|
|
220
|
-
this.textEditorModelHandle = undefined;
|
|
221
|
-
this.createdEditorModel = false;
|
|
222
|
-
super.dispose();
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
BaseTextEditorModel.AUTO_DETECT_LANGUAGE_THROTTLE_DELAY = 600;
|
|
226
|
-
BaseTextEditorModel = ( (__decorate([
|
|
227
|
-
( (__param(0, IModelService))),
|
|
228
|
-
( (__param(1, ILanguageService))),
|
|
229
|
-
( (__param(2, ILanguageDetectionService))),
|
|
230
|
-
( (__param(3, IAccessibilityService)))
|
|
231
|
-
], BaseTextEditorModel)));
|
|
232
29
|
let TextResourceEditorModel = class TextResourceEditorModel extends BaseTextEditorModel {
|
|
233
30
|
constructor(resource, languageService, modelService, languageDetectionService, accessibilityService) {
|
|
234
31
|
super(modelService, languageService, languageDetectionService, accessibilityService, resource);
|
|
@@ -246,7 +43,6 @@ TextResourceEditorModel = ( (__decorate([
|
|
|
246
43
|
( (__param(3, ILanguageDetectionService))),
|
|
247
44
|
( (__param(4, IAccessibilityService)))
|
|
248
45
|
], TextResourceEditorModel)));
|
|
249
|
-
class TextFileEditorModel {}
|
|
250
46
|
let ModelUndoRedoParticipant = class ModelUndoRedoParticipant extends Disposable {
|
|
251
47
|
constructor(_modelService, _textModelService, _undoRedoService) {
|
|
252
48
|
super();
|
|
@@ -275,7 +71,7 @@ let ModelUndoRedoParticipant = class ModelUndoRedoParticipant extends Disposable
|
|
|
275
71
|
if (missingModels.length === 0) {
|
|
276
72
|
return Disposable.None;
|
|
277
73
|
}
|
|
278
|
-
const disposablesPromises = missingModels.map(async (uri) => {
|
|
74
|
+
const disposablesPromises = ( (missingModels.map(async (uri) => {
|
|
279
75
|
try {
|
|
280
76
|
const reference = await this._textModelService.createModelReference(uri);
|
|
281
77
|
return reference;
|
|
@@ -283,7 +79,7 @@ let ModelUndoRedoParticipant = class ModelUndoRedoParticipant extends Disposable
|
|
|
283
79
|
catch (err) {
|
|
284
80
|
return Disposable.None;
|
|
285
81
|
}
|
|
286
|
-
});
|
|
82
|
+
})));
|
|
287
83
|
return Promise.all(disposablesPromises).then(disposables => {
|
|
288
84
|
return {
|
|
289
85
|
dispose: () => dispose(disposables)
|
|
@@ -635,8 +431,8 @@ let EditorService = class EditorService extends Disposable {
|
|
|
635
431
|
this.isOpened = () => false;
|
|
636
432
|
this.isVisible = () => false;
|
|
637
433
|
this.findEditors = () => [];
|
|
638
|
-
this.save =
|
|
639
|
-
this.saveAll =
|
|
434
|
+
this.save = async () => true;
|
|
435
|
+
this.saveAll = async () => true;
|
|
640
436
|
this.revert = unsupported;
|
|
641
437
|
this.revertAll = unsupported;
|
|
642
438
|
this.closeEditor = unsupported;
|
|
@@ -669,23 +465,14 @@ let EditorService = class EditorService extends Disposable {
|
|
|
669
465
|
throw new Error('Diff editors not supported');
|
|
670
466
|
}
|
|
671
467
|
let modelEditor;
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (model == null) {
|
|
676
|
-
const modelRef = await this.textModelService.createModelReference(resource);
|
|
677
|
-
newModelRef = modelRef;
|
|
678
|
-
model = modelRef.object.textEditorModel;
|
|
679
|
-
}
|
|
680
|
-
else {
|
|
681
|
-
const codeEditors = StandaloneServices.get(ICodeEditorService).listCodeEditors();
|
|
682
|
-
modelEditor = codeEditors.find(editor => editor.getModel() === model);
|
|
683
|
-
}
|
|
468
|
+
const modelRef = await this.textModelService.createModelReference(resource);
|
|
469
|
+
const codeEditors = StandaloneServices.get(ICodeEditorService).listCodeEditors();
|
|
470
|
+
modelEditor = codeEditors.find(editor => editor.getModel() === modelRef.object.textEditorModel);
|
|
684
471
|
if (modelEditor == null) {
|
|
685
|
-
modelEditor = await this._openEditor(
|
|
472
|
+
modelEditor = await this._openEditor(modelRef, options, preferredGroup === SIDE_GROUP);
|
|
686
473
|
}
|
|
687
474
|
if (modelEditor == null) {
|
|
688
|
-
|
|
475
|
+
modelRef.dispose();
|
|
689
476
|
return undefined;
|
|
690
477
|
}
|
|
691
478
|
if (options != null) {
|