@theia/editor 1.45.1 → 1.46.0-next.72

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 (112) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/decorations/editor-decoration-style.d.ts +8 -8
  3. package/lib/browser/decorations/editor-decoration-style.js +36 -36
  4. package/lib/browser/decorations/editor-decoration.d.ts +106 -106
  5. package/lib/browser/decorations/editor-decoration.js +37 -37
  6. package/lib/browser/decorations/editor-decorator.d.ts +6 -6
  7. package/lib/browser/decorations/editor-decorator.js +43 -43
  8. package/lib/browser/decorations/index.d.ts +3 -3
  9. package/lib/browser/decorations/index.js +30 -30
  10. package/lib/browser/diff-navigator.d.ts +9 -10
  11. package/lib/browser/diff-navigator.d.ts.map +1 -1
  12. package/lib/browser/diff-navigator.js +19 -19
  13. package/lib/browser/diff-navigator.js.map +1 -1
  14. package/lib/browser/editor-command.d.ts +102 -102
  15. package/lib/browser/editor-command.js +426 -426
  16. package/lib/browser/editor-contribution.d.ts +26 -26
  17. package/lib/browser/editor-contribution.js +198 -198
  18. package/lib/browser/editor-frontend-module.d.ts +5 -5
  19. package/lib/browser/editor-frontend-module.js +74 -74
  20. package/lib/browser/editor-generated-preference-schema.d.ts +282 -249
  21. package/lib/browser/editor-generated-preference-schema.d.ts.map +1 -1
  22. package/lib/browser/editor-generated-preference-schema.js +2451 -2316
  23. package/lib/browser/editor-generated-preference-schema.js.map +1 -1
  24. package/lib/browser/editor-keybinding.d.ts +5 -5
  25. package/lib/browser/editor-keybinding.js +55 -55
  26. package/lib/browser/editor-linenumber-contribution.d.ts +15 -15
  27. package/lib/browser/editor-linenumber-contribution.d.ts.map +1 -1
  28. package/lib/browser/editor-linenumber-contribution.js +95 -96
  29. package/lib/browser/editor-linenumber-contribution.js.map +1 -1
  30. package/lib/browser/editor-manager.d.ts +115 -115
  31. package/lib/browser/editor-manager.js +428 -428
  32. package/lib/browser/editor-menu.d.ts +48 -48
  33. package/lib/browser/editor-menu.js +210 -210
  34. package/lib/browser/editor-navigation-contribution.d.ts +67 -67
  35. package/lib/browser/editor-navigation-contribution.js +343 -343
  36. package/lib/browser/editor-preferences.d.ts +41 -41
  37. package/lib/browser/editor-preferences.js +176 -176
  38. package/lib/browser/editor-variable-contribution.d.ts +8 -8
  39. package/lib/browser/editor-variable-contribution.js +64 -64
  40. package/lib/browser/editor-widget-factory.d.ts +17 -17
  41. package/lib/browser/editor-widget-factory.js +91 -91
  42. package/lib/browser/editor-widget.d.ts +24 -24
  43. package/lib/browser/editor-widget.d.ts.map +1 -1
  44. package/lib/browser/editor-widget.js +122 -114
  45. package/lib/browser/editor-widget.js.map +1 -1
  46. package/lib/browser/editor.d.ts +295 -293
  47. package/lib/browser/editor.d.ts.map +1 -1
  48. package/lib/browser/editor.js +103 -103
  49. package/lib/browser/editor.js.map +1 -1
  50. package/lib/browser/index.d.ts +10 -10
  51. package/lib/browser/index.js +37 -37
  52. package/lib/browser/language-status/editor-language-status-service.d.ts +77 -77
  53. package/lib/browser/language-status/editor-language-status-service.js +251 -251
  54. package/lib/browser/navigation/navigation-location-service.d.ts +103 -103
  55. package/lib/browser/navigation/navigation-location-service.js +281 -281
  56. package/lib/browser/navigation/navigation-location-service.spec.d.ts +1 -1
  57. package/lib/browser/navigation/navigation-location-service.spec.js +184 -184
  58. package/lib/browser/navigation/navigation-location-similarity.d.ts +15 -15
  59. package/lib/browser/navigation/navigation-location-similarity.js +62 -62
  60. package/lib/browser/navigation/navigation-location-similarity.spec.d.ts +1 -1
  61. package/lib/browser/navigation/navigation-location-similarity.spec.js +32 -32
  62. package/lib/browser/navigation/navigation-location-updater.d.ts +35 -35
  63. package/lib/browser/navigation/navigation-location-updater.js +210 -210
  64. package/lib/browser/navigation/navigation-location-updater.spec.d.ts +1 -1
  65. package/lib/browser/navigation/navigation-location-updater.spec.js +177 -177
  66. package/lib/browser/navigation/navigation-location.d.ts +191 -191
  67. package/lib/browser/navigation/navigation-location.js +300 -300
  68. package/lib/browser/navigation/test/mock-navigation-location-updater.d.ts +15 -15
  69. package/lib/browser/navigation/test/mock-navigation-location-updater.js +38 -38
  70. package/lib/browser/quick-editor-service.d.ts +16 -16
  71. package/lib/browser/quick-editor-service.js +109 -109
  72. package/lib/browser/undo-redo-service.d.ts +23 -23
  73. package/lib/browser/undo-redo-service.js +110 -110
  74. package/lib/common/language-selector.d.ts +13 -13
  75. package/lib/common/language-selector.js +90 -90
  76. package/lib/package.spec.js +25 -25
  77. package/package.json +5 -5
  78. package/src/browser/decorations/editor-decoration-style.ts +41 -41
  79. package/src/browser/decorations/editor-decoration.ts +127 -127
  80. package/src/browser/decorations/editor-decorator.ts +36 -36
  81. package/src/browser/decorations/index.ts +19 -19
  82. package/src/browser/diff-navigator.ts +27 -28
  83. package/src/browser/editor-command.ts +414 -414
  84. package/src/browser/editor-contribution.ts +185 -185
  85. package/src/browser/editor-frontend-module.ts +87 -87
  86. package/src/browser/editor-generated-preference-schema.ts +2707 -2539
  87. package/src/browser/editor-keybinding.ts +55 -55
  88. package/src/browser/editor-linenumber-contribution.ts +88 -89
  89. package/src/browser/editor-manager.ts +442 -442
  90. package/src/browser/editor-menu.ts +224 -224
  91. package/src/browser/editor-navigation-contribution.ts +343 -343
  92. package/src/browser/editor-preferences.ts +226 -226
  93. package/src/browser/editor-variable-contribution.ts +54 -54
  94. package/src/browser/editor-widget-factory.ts +82 -82
  95. package/src/browser/editor-widget.ts +137 -130
  96. package/src/browser/editor.ts +360 -358
  97. package/src/browser/index.ts +26 -26
  98. package/src/browser/language-status/editor-language-status-service.ts +271 -271
  99. package/src/browser/language-status/editor-language-status.css +101 -101
  100. package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
  101. package/src/browser/navigation/navigation-location-service.ts +284 -284
  102. package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
  103. package/src/browser/navigation/navigation-location-similarity.ts +58 -58
  104. package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
  105. package/src/browser/navigation/navigation-location-updater.ts +220 -220
  106. package/src/browser/navigation/navigation-location.ts +418 -418
  107. package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
  108. package/src/browser/quick-editor-service.ts +94 -94
  109. package/src/browser/style/index.css +19 -19
  110. package/src/browser/undo-redo-service.ts +120 -120
  111. package/src/common/language-selector.ts +104 -104
  112. package/src/package.spec.ts +28 -28
@@ -1,358 +1,360 @@
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
-
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-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
+
298
+ export interface Dimension {
299
+ width: number;
300
+ height: number;
301
+ }
302
+
303
+ export interface TextEditorSelection {
304
+ uri: URI
305
+ cursor?: Position
306
+ selection?: Range
307
+ }
308
+
309
+ export interface RevealPositionOptions {
310
+ vertical: 'auto' | 'center' | 'centerIfOutsideViewport';
311
+ horizontal?: boolean;
312
+ }
313
+
314
+ export interface RevealRangeOptions {
315
+ at: 'auto' | 'center' | 'top' | 'centerIfOutsideViewport';
316
+ }
317
+
318
+ export interface DeltaDecorationParams {
319
+ oldDecorations: string[];
320
+ newDecorations: EditorDecoration[];
321
+ }
322
+
323
+ export interface ReplaceTextParams {
324
+ /**
325
+ * the source to edit
326
+ */
327
+ source: string;
328
+ /**
329
+ * the replace operations
330
+ */
331
+ replaceOperations: ReplaceOperation[];
332
+ }
333
+
334
+ export interface ReplaceOperation {
335
+ /**
336
+ * the position that shall be replaced
337
+ */
338
+ range: Range;
339
+ /**
340
+ * the text to replace with
341
+ */
342
+ text: string;
343
+ }
344
+
345
+ export namespace TextEditorSelection {
346
+ export function is(arg: unknown): arg is TextEditorSelection {
347
+ return isObject<TextEditorSelection>(arg) && arg.uri instanceof URI;
348
+ }
349
+ }
350
+
351
+ export namespace CustomEditorWidget {
352
+ export function is(arg: Widget | undefined): arg is CustomEditorWidget {
353
+ return !!arg && 'modelRef' in arg;
354
+ }
355
+ }
356
+
357
+ export interface CustomEditorWidget extends Widget {
358
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
359
+ readonly modelRef: Reference<any>;
360
+ }