@theia/editor 1.53.0-next.5 → 1.53.0-next.55

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.
Files changed (48) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/editor-manager.d.ts.map +1 -1
  3. package/lib/browser/editor-manager.js +11 -4
  4. package/lib/browser/editor-manager.js.map +1 -1
  5. package/lib/browser/editor-variable-contribution.d.ts.map +1 -1
  6. package/lib/browser/editor-variable-contribution.js +9 -1
  7. package/lib/browser/editor-variable-contribution.js.map +1 -1
  8. package/lib/browser/editor.d.ts +5 -2
  9. package/lib/browser/editor.d.ts.map +1 -1
  10. package/lib/browser/editor.js.map +1 -1
  11. package/lib/browser/navigation/navigation-location-service.js +3 -3
  12. package/package.json +5 -5
  13. package/src/browser/decorations/editor-decoration-style.ts +41 -41
  14. package/src/browser/decorations/editor-decoration.ts +127 -127
  15. package/src/browser/decorations/editor-decorator.ts +36 -36
  16. package/src/browser/decorations/index.ts +19 -19
  17. package/src/browser/diff-navigator.ts +27 -27
  18. package/src/browser/editor-command.ts +393 -393
  19. package/src/browser/editor-contribution.ts +185 -185
  20. package/src/browser/editor-frontend-module.ts +90 -90
  21. package/src/browser/editor-generated-preference-schema.ts +2956 -2956
  22. package/src/browser/editor-keybinding.ts +55 -55
  23. package/src/browser/editor-language-quick-pick-service.ts +68 -68
  24. package/src/browser/editor-linenumber-contribution.ts +88 -88
  25. package/src/browser/editor-manager.ts +462 -452
  26. package/src/browser/editor-menu.ts +224 -224
  27. package/src/browser/editor-navigation-contribution.ts +343 -343
  28. package/src/browser/editor-preferences.ts +226 -226
  29. package/src/browser/editor-variable-contribution.ts +62 -54
  30. package/src/browser/editor-widget-factory.ts +82 -82
  31. package/src/browser/editor-widget.ts +139 -139
  32. package/src/browser/editor.ts +366 -362
  33. package/src/browser/index.ts +26 -26
  34. package/src/browser/language-status/editor-language-status-service.ts +271 -271
  35. package/src/browser/language-status/editor-language-status.css +101 -101
  36. package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
  37. package/src/browser/navigation/navigation-location-service.ts +284 -284
  38. package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
  39. package/src/browser/navigation/navigation-location-similarity.ts +58 -58
  40. package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
  41. package/src/browser/navigation/navigation-location-updater.ts +220 -220
  42. package/src/browser/navigation/navigation-location.ts +418 -418
  43. package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
  44. package/src/browser/quick-editor-service.ts +94 -94
  45. package/src/browser/style/index.css +19 -19
  46. package/src/browser/undo-redo-service.ts +120 -120
  47. package/src/common/language-selector.ts +104 -104
  48. package/src/package.spec.ts +28 -28
@@ -1,362 +1,366 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { Position, Range, Location } from '@theia/core/shared/vscode-languageserver-protocol';
18
- import * as lsp from '@theia/core/shared/vscode-languageserver-protocol';
19
- import URI from '@theia/core/lib/common/uri';
20
- import { Event, Disposable, TextDocumentContentChangeDelta, Reference, isObject } from '@theia/core/lib/common';
21
- import { Saveable, Navigatable, Widget } from '@theia/core/lib/browser';
22
- import { EditorDecoration } from './decorations/editor-decoration';
23
- import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
24
-
25
- export { Position, Range, Location };
26
-
27
- export const TextEditorProvider = Symbol('TextEditorProvider');
28
- export type TextEditorProvider = (uri: URI) => Promise<TextEditor>;
29
-
30
- export interface TextEditorDocument extends lsp.TextDocument, Saveable, Disposable {
31
- getLineContent(lineNumber: number): string;
32
- getLineMaxColumn(lineNumber: number): number;
33
- /**
34
- * @since 1.8.0
35
- */
36
- findMatches?(options: FindMatchesOptions): FindMatch[];
37
- /**
38
- * Creates a valid position. If the position is outside of the backing document, this method will return a position that is ensured to be inside the document and valid.
39
- * For example, when the `position` is `{ line: 1, character: 0 }` and the document is empty, this method will return with `{ line: 0, character: 0 }`.
40
- */
41
- toValidPosition(position: Position): Position;
42
- /**
43
- * Creates a valid range. If the `range` argument is outside of the document, this method will return with a new range that does not exceed the boundaries of the document.
44
- * For example, if the argument is `{ start: { line: 1, character: 0 }, end: { line: 1, character: 0 } }` and the document is empty, the return value is
45
- * `{ start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }`.
46
- */
47
- toValidRange(range: Range): Range;
48
- }
49
-
50
- // Refactoring
51
- export { TextDocumentContentChangeDelta };
52
-
53
- export interface TextDocumentChangeEvent {
54
- readonly document: TextEditorDocument;
55
- readonly contentChanges: TextDocumentContentChangeDelta[];
56
- }
57
-
58
- /**
59
- * Type of hit element with the mouse in the editor.
60
- * Copied from monaco editor.
61
- */
62
- export enum MouseTargetType {
63
- /**
64
- * Mouse is on top of an unknown element.
65
- */
66
- UNKNOWN = 0,
67
- /**
68
- * Mouse is on top of the textarea used for input.
69
- */
70
- TEXTAREA = 1,
71
- /**
72
- * Mouse is on top of the glyph margin
73
- */
74
- GUTTER_GLYPH_MARGIN = 2,
75
- /**
76
- * Mouse is on top of the line numbers
77
- */
78
- GUTTER_LINE_NUMBERS = 3,
79
- /**
80
- * Mouse is on top of the line decorations
81
- */
82
- GUTTER_LINE_DECORATIONS = 4,
83
- /**
84
- * Mouse is on top of the whitespace left in the gutter by a view zone.
85
- */
86
- GUTTER_VIEW_ZONE = 5,
87
- /**
88
- * Mouse is on top of text in the content.
89
- */
90
- CONTENT_TEXT = 6,
91
- /**
92
- * Mouse is on top of empty space in the content (e.g. after line text or below last line)
93
- */
94
- CONTENT_EMPTY = 7,
95
- /**
96
- * Mouse is on top of a view zone in the content.
97
- */
98
- CONTENT_VIEW_ZONE = 8,
99
- /**
100
- * Mouse is on top of a content widget.
101
- */
102
- CONTENT_WIDGET = 9,
103
- /**
104
- * Mouse is on top of the decorations overview ruler.
105
- */
106
- OVERVIEW_RULER = 10,
107
- /**
108
- * Mouse is on top of a scrollbar.
109
- */
110
- SCROLLBAR = 11,
111
- /**
112
- * Mouse is on top of an overlay widget.
113
- */
114
- OVERLAY_WIDGET = 12,
115
- /**
116
- * Mouse is outside of the editor.
117
- */
118
- OUTSIDE_EDITOR = 13,
119
- }
120
-
121
- export interface MouseTarget {
122
- /**
123
- * The target element
124
- */
125
- readonly element?: Element;
126
- /**
127
- * The target type
128
- */
129
- readonly type: MouseTargetType;
130
- /**
131
- * The 'approximate' editor position
132
- */
133
- readonly position?: Position;
134
- /**
135
- * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line).
136
- */
137
- readonly mouseColumn: number;
138
- /**
139
- * The 'approximate' editor range
140
- */
141
- readonly range?: Range;
142
- /**
143
- * Some extra detail.
144
- */
145
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
- readonly detail: any;
147
- }
148
-
149
- export interface EditorMouseEvent {
150
- readonly event: MouseEvent;
151
- readonly target: MouseTarget;
152
- }
153
-
154
- export const enum EncodingMode {
155
-
156
- /**
157
- * Instructs the encoding support to encode the current input with the provided encoding
158
- */
159
- Encode,
160
-
161
- /**
162
- * Instructs the encoding support to decode the current input with the provided encoding
163
- */
164
- Decode
165
- }
166
-
167
- /**
168
- * Options for searching in an editor.
169
- */
170
- export interface FindMatchesOptions {
171
- /**
172
- * The string used to search. If it is a regular expression, set `isRegex` to true.
173
- */
174
- searchString: string;
175
- /**
176
- * Used to indicate that `searchString` is a regular expression.
177
- */
178
- isRegex: boolean;
179
- /**
180
- * Force the matching to match lower/upper case exactly.
181
- */
182
- matchCase: boolean;
183
- /**
184
- * Force the matching to match entire words only.
185
- */
186
- matchWholeWord: boolean;
187
- /**
188
- * Limit the number of results.
189
- */
190
- limitResultCount?: number;
191
- }
192
-
193
- /**
194
- * Representation of a find match.
195
- */
196
- export interface FindMatch {
197
- /**
198
- * The textual match.
199
- */
200
- readonly matches: string[];
201
- /**
202
- * The range for the given match.
203
- */
204
- readonly range: Range;
205
- }
206
-
207
- export interface TextEditor extends Disposable, TextEditorSelection, Navigatable {
208
- readonly node: HTMLElement;
209
-
210
- readonly uri: URI;
211
- readonly isReadonly: boolean | MarkdownString;
212
- readonly onDidChangeReadOnly: Event<boolean | MarkdownString>;
213
- readonly document: TextEditorDocument;
214
- readonly onDocumentContentChanged: Event<TextDocumentChangeEvent>;
215
-
216
- cursor: Position;
217
- readonly onCursorPositionChanged: Event<Position>;
218
-
219
- selection: Range;
220
- readonly onSelectionChanged: Event<Range>;
221
-
222
- /**
223
- * The text editor should be revealed,
224
- * otherwise it won't receive the focus.
225
- */
226
- focus(): void;
227
- blur(): void;
228
- isFocused(): boolean;
229
- readonly onFocusChanged: Event<boolean>;
230
-
231
- readonly onMouseDown: Event<EditorMouseEvent>;
232
-
233
- readonly onScrollChanged: Event<void>;
234
- getVisibleRanges(): Range[];
235
-
236
- revealPosition(position: Position, options?: RevealPositionOptions): void;
237
- revealRange(range: Range, options?: RevealRangeOptions): void;
238
-
239
- /**
240
- * Rerender the editor.
241
- */
242
- refresh(): void;
243
- /**
244
- * Resize the editor to fit its node.
245
- */
246
- resizeToFit(): void;
247
- setSize(size: Dimension): void;
248
-
249
- /**
250
- * Applies given new decorations, and removes old decorations identified by ids.
251
- *
252
- * @returns identifiers of applied decorations, which can be removed in next call.
253
- */
254
- deltaDecorations(params: DeltaDecorationParams): string[];
255
-
256
- /**
257
- * Gets all the decorations for the lines between `startLineNumber` and `endLineNumber` as an array.
258
- * @param startLineNumber The start line number.
259
- * @param endLineNumber The end line number.
260
- * @return An array with the decorations.
261
- */
262
- getLinesDecorations(startLineNumber: number, endLineNumber: number): EditorDecoration[];
263
-
264
- getVisibleColumn(position: Position): number;
265
-
266
- /**
267
- * Replaces the text of source given in ReplaceTextParams.
268
- * @param params: ReplaceTextParams
269
- */
270
- replaceText(params: ReplaceTextParams): Promise<boolean>;
271
-
272
- /**
273
- * Execute edits on the editor.
274
- * @param edits: edits created with `lsp.TextEdit.replace`, `lsp.TextEdit.insert`, `lsp.TextEdit.del`
275
- */
276
- executeEdits(edits: lsp.TextEdit[]): boolean;
277
-
278
- storeViewState(): object;
279
- restoreViewState(state: object): void;
280
-
281
- detectLanguage(): void;
282
- setLanguage(languageId: string): void;
283
- readonly onLanguageChanged: Event<string>;
284
-
285
- /**
286
- * Gets the encoding of the input if known.
287
- */
288
- getEncoding(): string;
289
-
290
- /**
291
- * Sets the encoding for the input for saving.
292
- */
293
- setEncoding(encoding: string, mode: EncodingMode): void;
294
-
295
- readonly onEncodingChanged: Event<string>;
296
-
297
- shouldDisplayDirtyDiff(): boolean;
298
- }
299
-
300
- export interface Dimension {
301
- width: number;
302
- height: number;
303
- }
304
-
305
- export interface TextEditorSelection {
306
- uri: URI
307
- cursor?: Position
308
- selection?: Range
309
- }
310
-
311
- export interface RevealPositionOptions {
312
- vertical: 'auto' | 'center' | 'centerIfOutsideViewport';
313
- horizontal?: boolean;
314
- }
315
-
316
- export interface RevealRangeOptions {
317
- at: 'auto' | 'center' | 'top' | 'centerIfOutsideViewport';
318
- }
319
-
320
- export interface DeltaDecorationParams {
321
- oldDecorations: string[];
322
- newDecorations: EditorDecoration[];
323
- }
324
-
325
- export interface ReplaceTextParams {
326
- /**
327
- * the source to edit
328
- */
329
- source: string;
330
- /**
331
- * the replace operations
332
- */
333
- replaceOperations: ReplaceOperation[];
334
- }
335
-
336
- export interface ReplaceOperation {
337
- /**
338
- * the position that shall be replaced
339
- */
340
- range: Range;
341
- /**
342
- * the text to replace with
343
- */
344
- text: string;
345
- }
346
-
347
- export namespace TextEditorSelection {
348
- export function is(arg: unknown): arg is TextEditorSelection {
349
- return isObject<TextEditorSelection>(arg) && arg.uri instanceof URI;
350
- }
351
- }
352
-
353
- export namespace CustomEditorWidget {
354
- export function is(arg: Widget | undefined): arg is CustomEditorWidget {
355
- return !!arg && 'modelRef' in arg;
356
- }
357
- }
358
-
359
- export interface CustomEditorWidget extends Widget {
360
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
361
- readonly modelRef: Reference<any>;
362
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { Position, Range, Location } from '@theia/core/shared/vscode-languageserver-protocol';
18
+ import * as lsp from '@theia/core/shared/vscode-languageserver-protocol';
19
+ import URI from '@theia/core/lib/common/uri';
20
+ import { Event, Disposable, TextDocumentContentChangeDelta, Reference, isObject } from '@theia/core/lib/common';
21
+ import { Saveable, Navigatable, Widget } from '@theia/core/lib/browser';
22
+ import { EditorDecoration } from './decorations/editor-decoration';
23
+ import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
24
+
25
+ export { Position, Range, Location };
26
+
27
+ export const TextEditorProvider = Symbol('TextEditorProvider');
28
+ export type TextEditorProvider = (uri: URI) => Promise<TextEditor>;
29
+
30
+ export interface TextEditorDocument extends lsp.TextDocument, Saveable, Disposable {
31
+ getLineContent(lineNumber: number): string;
32
+ getLineMaxColumn(lineNumber: number): number;
33
+ /**
34
+ * @since 1.8.0
35
+ */
36
+ findMatches?(options: FindMatchesOptions): FindMatch[];
37
+ /**
38
+ * Creates a valid position. If the position is outside of the backing document, this method will return a position that is ensured to be inside the document and valid.
39
+ * For example, when the `position` is `{ line: 1, character: 0 }` and the document is empty, this method will return with `{ line: 0, character: 0 }`.
40
+ */
41
+ toValidPosition(position: Position): Position;
42
+ /**
43
+ * Creates a valid range. If the `range` argument is outside of the document, this method will return with a new range that does not exceed the boundaries of the document.
44
+ * For example, if the argument is `{ start: { line: 1, character: 0 }, end: { line: 1, character: 0 } }` and the document is empty, the return value is
45
+ * `{ start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }`.
46
+ */
47
+ toValidRange(range: Range): Range;
48
+ }
49
+
50
+ // Refactoring
51
+ export { TextDocumentContentChangeDelta };
52
+
53
+ export interface TextDocumentChangeEvent {
54
+ readonly document: TextEditorDocument;
55
+ readonly contentChanges: TextDocumentContentChangeDelta[];
56
+ }
57
+
58
+ /**
59
+ * Type of hit element with the mouse in the editor.
60
+ * Copied from monaco editor.
61
+ */
62
+ export enum MouseTargetType {
63
+ /**
64
+ * Mouse is on top of an unknown element.
65
+ */
66
+ UNKNOWN = 0,
67
+ /**
68
+ * Mouse is on top of the textarea used for input.
69
+ */
70
+ TEXTAREA = 1,
71
+ /**
72
+ * Mouse is on top of the glyph margin
73
+ */
74
+ GUTTER_GLYPH_MARGIN = 2,
75
+ /**
76
+ * Mouse is on top of the line numbers
77
+ */
78
+ GUTTER_LINE_NUMBERS = 3,
79
+ /**
80
+ * Mouse is on top of the line decorations
81
+ */
82
+ GUTTER_LINE_DECORATIONS = 4,
83
+ /**
84
+ * Mouse is on top of the whitespace left in the gutter by a view zone.
85
+ */
86
+ GUTTER_VIEW_ZONE = 5,
87
+ /**
88
+ * Mouse is on top of text in the content.
89
+ */
90
+ CONTENT_TEXT = 6,
91
+ /**
92
+ * Mouse is on top of empty space in the content (e.g. after line text or below last line)
93
+ */
94
+ CONTENT_EMPTY = 7,
95
+ /**
96
+ * Mouse is on top of a view zone in the content.
97
+ */
98
+ CONTENT_VIEW_ZONE = 8,
99
+ /**
100
+ * Mouse is on top of a content widget.
101
+ */
102
+ CONTENT_WIDGET = 9,
103
+ /**
104
+ * Mouse is on top of the decorations overview ruler.
105
+ */
106
+ OVERVIEW_RULER = 10,
107
+ /**
108
+ * Mouse is on top of a scrollbar.
109
+ */
110
+ SCROLLBAR = 11,
111
+ /**
112
+ * Mouse is on top of an overlay widget.
113
+ */
114
+ OVERLAY_WIDGET = 12,
115
+ /**
116
+ * Mouse is outside of the editor.
117
+ */
118
+ OUTSIDE_EDITOR = 13,
119
+ }
120
+
121
+ export interface MouseTarget {
122
+ /**
123
+ * The target element
124
+ */
125
+ readonly element?: Element;
126
+ /**
127
+ * The target type
128
+ */
129
+ readonly type: MouseTargetType;
130
+ /**
131
+ * The 'approximate' editor position
132
+ */
133
+ readonly position?: Position;
134
+ /**
135
+ * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line).
136
+ */
137
+ readonly mouseColumn: number;
138
+ /**
139
+ * The 'approximate' editor range
140
+ */
141
+ readonly range?: Range;
142
+ /**
143
+ * Some extra detail.
144
+ */
145
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
+ readonly detail: any;
147
+ }
148
+
149
+ export interface EditorMouseEvent {
150
+ readonly event: MouseEvent;
151
+ readonly target: MouseTarget;
152
+ }
153
+
154
+ export const enum EncodingMode {
155
+
156
+ /**
157
+ * Instructs the encoding support to encode the current input with the provided encoding
158
+ */
159
+ Encode,
160
+
161
+ /**
162
+ * Instructs the encoding support to decode the current input with the provided encoding
163
+ */
164
+ Decode
165
+ }
166
+
167
+ /**
168
+ * Options for searching in an editor.
169
+ */
170
+ export interface FindMatchesOptions {
171
+ /**
172
+ * The string used to search. If it is a regular expression, set `isRegex` to true.
173
+ */
174
+ searchString: string;
175
+ /**
176
+ * Used to indicate that `searchString` is a regular expression.
177
+ */
178
+ isRegex: boolean;
179
+ /**
180
+ * Force the matching to match lower/upper case exactly.
181
+ */
182
+ matchCase: boolean;
183
+ /**
184
+ * Force the matching to match entire words only.
185
+ */
186
+ matchWholeWord: boolean;
187
+ /**
188
+ * Limit the number of results.
189
+ */
190
+ limitResultCount?: number;
191
+ }
192
+
193
+ /**
194
+ * Representation of a find match.
195
+ */
196
+ export interface FindMatch {
197
+ /**
198
+ * The textual match.
199
+ */
200
+ readonly matches: string[];
201
+ /**
202
+ * The range for the given match.
203
+ */
204
+ readonly range: Range;
205
+ }
206
+
207
+ export interface TextEditor extends Disposable, TextEditorSelection, Navigatable {
208
+ readonly node: HTMLElement;
209
+
210
+ readonly uri: URI;
211
+ readonly isReadonly: boolean | MarkdownString;
212
+ readonly onDidChangeReadOnly: Event<boolean | MarkdownString>;
213
+ readonly document: TextEditorDocument;
214
+ readonly onDocumentContentChanged: Event<TextDocumentChangeEvent>;
215
+
216
+ cursor: Position;
217
+ readonly onCursorPositionChanged: Event<Position>;
218
+
219
+ selection: Selection;
220
+ readonly onSelectionChanged: Event<Selection>;
221
+
222
+ /**
223
+ * The text editor should be revealed,
224
+ * otherwise it won't receive the focus.
225
+ */
226
+ focus(): void;
227
+ blur(): void;
228
+ isFocused(): boolean;
229
+ readonly onFocusChanged: Event<boolean>;
230
+
231
+ readonly onMouseDown: Event<EditorMouseEvent>;
232
+
233
+ readonly onScrollChanged: Event<void>;
234
+ getVisibleRanges(): Range[];
235
+
236
+ revealPosition(position: Position, options?: RevealPositionOptions): void;
237
+ revealRange(range: Range, options?: RevealRangeOptions): void;
238
+
239
+ /**
240
+ * Rerender the editor.
241
+ */
242
+ refresh(): void;
243
+ /**
244
+ * Resize the editor to fit its node.
245
+ */
246
+ resizeToFit(): void;
247
+ setSize(size: Dimension): void;
248
+
249
+ /**
250
+ * Applies given new decorations, and removes old decorations identified by ids.
251
+ *
252
+ * @returns identifiers of applied decorations, which can be removed in next call.
253
+ */
254
+ deltaDecorations(params: DeltaDecorationParams): string[];
255
+
256
+ /**
257
+ * Gets all the decorations for the lines between `startLineNumber` and `endLineNumber` as an array.
258
+ * @param startLineNumber The start line number.
259
+ * @param endLineNumber The end line number.
260
+ * @return An array with the decorations.
261
+ */
262
+ getLinesDecorations(startLineNumber: number, endLineNumber: number): EditorDecoration[];
263
+
264
+ getVisibleColumn(position: Position): number;
265
+
266
+ /**
267
+ * Replaces the text of source given in ReplaceTextParams.
268
+ * @param params: ReplaceTextParams
269
+ */
270
+ replaceText(params: ReplaceTextParams): Promise<boolean>;
271
+
272
+ /**
273
+ * Execute edits on the editor.
274
+ * @param edits: edits created with `lsp.TextEdit.replace`, `lsp.TextEdit.insert`, `lsp.TextEdit.del`
275
+ */
276
+ executeEdits(edits: lsp.TextEdit[]): boolean;
277
+
278
+ storeViewState(): object;
279
+ restoreViewState(state: object): void;
280
+
281
+ detectLanguage(): void;
282
+ setLanguage(languageId: string): void;
283
+ readonly onLanguageChanged: Event<string>;
284
+
285
+ /**
286
+ * Gets the encoding of the input if known.
287
+ */
288
+ getEncoding(): string;
289
+
290
+ /**
291
+ * Sets the encoding for the input for saving.
292
+ */
293
+ setEncoding(encoding: string, mode: EncodingMode): void;
294
+
295
+ readonly onEncodingChanged: Event<string>;
296
+
297
+ shouldDisplayDirtyDiff(): boolean;
298
+ }
299
+
300
+ export interface Selection extends Range {
301
+ direction: 'ltr' | 'rtl';
302
+ }
303
+
304
+ export interface Dimension {
305
+ width: number;
306
+ height: number;
307
+ }
308
+
309
+ export interface TextEditorSelection {
310
+ uri: URI
311
+ cursor?: Position
312
+ selection?: Range
313
+ }
314
+
315
+ export interface RevealPositionOptions {
316
+ vertical: 'auto' | 'center' | 'centerIfOutsideViewport';
317
+ horizontal?: boolean;
318
+ }
319
+
320
+ export interface RevealRangeOptions {
321
+ at: 'auto' | 'center' | 'top' | 'centerIfOutsideViewport';
322
+ }
323
+
324
+ export interface DeltaDecorationParams {
325
+ oldDecorations: string[];
326
+ newDecorations: EditorDecoration[];
327
+ }
328
+
329
+ export interface ReplaceTextParams {
330
+ /**
331
+ * the source to edit
332
+ */
333
+ source: string;
334
+ /**
335
+ * the replace operations
336
+ */
337
+ replaceOperations: ReplaceOperation[];
338
+ }
339
+
340
+ export interface ReplaceOperation {
341
+ /**
342
+ * the position that shall be replaced
343
+ */
344
+ range: Range;
345
+ /**
346
+ * the text to replace with
347
+ */
348
+ text: string;
349
+ }
350
+
351
+ export namespace TextEditorSelection {
352
+ export function is(arg: unknown): arg is TextEditorSelection {
353
+ return isObject<TextEditorSelection>(arg) && arg.uri instanceof URI;
354
+ }
355
+ }
356
+
357
+ export namespace CustomEditorWidget {
358
+ export function is(arg: Widget | undefined): arg is CustomEditorWidget {
359
+ return !!arg && 'modelRef' in arg;
360
+ }
361
+ }
362
+
363
+ export interface CustomEditorWidget extends Widget {
364
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
365
+ readonly modelRef: Reference<any>;
366
+ }