@theia/editor 1.34.2 → 1.34.3

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