@opensumi/sumi 2.12.1-next-079c1930

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 (37) hide show
  1. package/README.md +1 -0
  2. package/build.ts +18 -0
  3. package/index.d.ts +5 -0
  4. package/manifest.json +414 -0
  5. package/package.json +18 -0
  6. package/sumi-browser.d.ts +273 -0
  7. package/sumi-worker/sumi-worker.d.ts +2788 -0
  8. package/sumi-worker/worker.command.d.ts +86 -0
  9. package/sumi-worker/worker.comments.d.ts +273 -0
  10. package/sumi-worker/worker.doc.d.ts +356 -0
  11. package/sumi-worker/worker.editor.d.ts +725 -0
  12. package/sumi-worker/worker.extensions.d.ts +63 -0
  13. package/sumi-worker/worker.language.d.ts +2220 -0
  14. package/sumi-worker/worker.window.d.ts +318 -0
  15. package/sumi-worker.d.ts +7 -0
  16. package/sumi.d.ts +822 -0
  17. package/vscode/typings/vscode.authentication.d.ts +231 -0
  18. package/vscode/typings/vscode.command.d.ts +86 -0
  19. package/vscode/typings/vscode.comments.d.ts +292 -0
  20. package/vscode/typings/vscode.d.ts +3789 -0
  21. package/vscode/typings/vscode.debug.d.ts +684 -0
  22. package/vscode/typings/vscode.doc.d.ts +272 -0
  23. package/vscode/typings/vscode.editor.d.ts +1017 -0
  24. package/vscode/typings/vscode.env.d.ts +153 -0
  25. package/vscode/typings/vscode.extension.d.ts +67 -0
  26. package/vscode/typings/vscode.language.d.ts +2630 -0
  27. package/vscode/typings/vscode.message.d.ts +195 -0
  28. package/vscode/typings/vscode.proposed.d.ts +662 -0
  29. package/vscode/typings/vscode.quickpick.d.ts +491 -0
  30. package/vscode/typings/vscode.scm.d.ts +254 -0
  31. package/vscode/typings/vscode.tasks.d.ts +676 -0
  32. package/vscode/typings/vscode.theme.d.ts +370 -0
  33. package/vscode/typings/vscode.window.d.ts +870 -0
  34. package/vscode/typings/vscode.workspace.d.ts +664 -0
  35. package/vscode/typings-pending/vscode.d.ts +27 -0
  36. package/vscode/typings-pending/vscode.proposed.d.ts +3 -0
  37. package/vscode.d.ts +23 -0
@@ -0,0 +1,1017 @@
1
+ /**
2
+ * API OWENR: 吭头
3
+ */
4
+
5
+
6
+ declare module 'vscode' {
7
+
8
+ /**
9
+ * Represents sources that can cause [selection change events](#window.onDidChangeTextEditorSelection).
10
+ */
11
+ export enum TextEditorSelectionChangeKind {
12
+ /**
13
+ * Selection changed due to typing in the editor.
14
+ */
15
+ Keyboard = 1,
16
+ /**
17
+ * Selection change due to clicking in the editor.
18
+ */
19
+ Mouse = 2,
20
+ /**
21
+ * Selection changed because a command ran.
22
+ */
23
+ Command = 3
24
+ }
25
+
26
+ /**
27
+ * Represents an event describing the change in a [text editor's selections](#TextEditor.selections).
28
+ */
29
+ export interface TextEditorSelectionChangeEvent {
30
+ /**
31
+ * The [text editor](#TextEditor) for which the selections have changed.
32
+ */
33
+ readonly textEditor: TextEditor;
34
+ /**
35
+ * The new value for the [text editor's selections](#TextEditor.selections).
36
+ */
37
+ readonly selections: ReadonlyArray<Selection>;
38
+ /**
39
+ * The [change kind](#TextEditorSelectionChangeKind) which has triggered this
40
+ * event. Can be `undefined`.
41
+ */
42
+ readonly kind?: TextEditorSelectionChangeKind;
43
+ }
44
+
45
+ /**
46
+ * Represents an event describing the change in a [text editor's visible ranges](#TextEditor.visibleRanges).
47
+ */
48
+ export interface TextEditorVisibleRangesChangeEvent {
49
+ /**
50
+ * The [text editor](#TextEditor) for which the visible ranges have changed.
51
+ */
52
+ readonly textEditor: TextEditor;
53
+ /**
54
+ * The new value for the [text editor's visible ranges](#TextEditor.visibleRanges).
55
+ */
56
+ readonly visibleRanges: ReadonlyArray<Range>;
57
+ }
58
+
59
+ /**
60
+ * Represents an event describing the change in a [text editor's options](#TextEditor.options).
61
+ */
62
+ export interface TextEditorOptionsChangeEvent {
63
+ /**
64
+ * The [text editor](#TextEditor) for which the options have changed.
65
+ */
66
+ readonly textEditor: TextEditor;
67
+ /**
68
+ * The new value for the [text editor's options](#TextEditor.options).
69
+ */
70
+ readonly options: TextEditorOptions;
71
+ }
72
+
73
+ /**
74
+ * Represents an event describing the change of a [text editor's view column](#TextEditor.viewColumn).
75
+ */
76
+ export interface TextEditorViewColumnChangeEvent {
77
+ /**
78
+ * The [text editor](#TextEditor) for which the view column has changed.
79
+ */
80
+ readonly textEditor: TextEditor;
81
+ /**
82
+ * The new value for the [text editor's view column](#TextEditor.viewColumn).
83
+ */
84
+ readonly viewColumn: ViewColumn;
85
+ }
86
+
87
+ /**
88
+ * Rendering style of the cursor.
89
+ */
90
+ export enum TextEditorCursorStyle {
91
+ /**
92
+ * Render the cursor as a vertical thick line.
93
+ */
94
+ Line = 1,
95
+ /**
96
+ * Render the cursor as a block filled.
97
+ */
98
+ Block = 2,
99
+ /**
100
+ * Render the cursor as a thick horizontal line.
101
+ */
102
+ Underline = 3,
103
+ /**
104
+ * Render the cursor as a vertical thin line.
105
+ */
106
+ LineThin = 4,
107
+ /**
108
+ * Render the cursor as a block outlined.
109
+ */
110
+ BlockOutline = 5,
111
+ /**
112
+ * Render the cursor as a thin horizontal line.
113
+ */
114
+ UnderlineThin = 6
115
+ }
116
+
117
+ /**
118
+ * Rendering style of the line numbers.
119
+ */
120
+ export enum TextEditorLineNumbersStyle {
121
+ /**
122
+ * Do not render the line numbers.
123
+ */
124
+ Off = 0,
125
+ /**
126
+ * Render the line numbers.
127
+ */
128
+ On = 1,
129
+ /**
130
+ * Render the line numbers with values relative to the primary cursor location.
131
+ */
132
+ Relative = 2
133
+ }
134
+
135
+ /**
136
+ * Represents a [text editor](#TextEditor)'s [options](#TextEditor.options).
137
+ */
138
+ export interface TextEditorOptions {
139
+
140
+ /**
141
+ * The size in spaces a tab takes. This is used for two purposes:
142
+ * - the rendering width of a tab character;
143
+ * - the number of spaces to insert when [insertSpaces](#TextEditorOptions.insertSpaces) is true.
144
+ *
145
+ * When getting a text editor's options, this property will always be a number (resolved).
146
+ * When setting a text editor's options, this property is optional and it can be a number or `"auto"`.
147
+ */
148
+ tabSize?: number | string;
149
+
150
+ /**
151
+ * When pressing Tab insert [n](#TextEditorOptions.tabSize) spaces.
152
+ * When getting a text editor's options, this property will always be a boolean (resolved).
153
+ * When setting a text editor's options, this property is optional and it can be a boolean or `"auto"`.
154
+ */
155
+ insertSpaces?: boolean | string;
156
+
157
+ /**
158
+ * The rendering style of the cursor in this editor.
159
+ * When getting a text editor's options, this property will always be present.
160
+ * When setting a text editor's options, this property is optional.
161
+ */
162
+ cursorStyle?: TextEditorCursorStyle;
163
+
164
+ /**
165
+ * Render relative line numbers w.r.t. the current line number.
166
+ * When getting a text editor's options, this property will always be present.
167
+ * When setting a text editor's options, this property is optional.
168
+ */
169
+ lineNumbers?: TextEditorLineNumbersStyle;
170
+ }
171
+
172
+ /**
173
+ * Represents a handle to a set of decorations
174
+ * sharing the same [styling options](#DecorationRenderOptions) in a [text editor](#TextEditor).
175
+ *
176
+ * To get an instance of a `TextEditorDecorationType` use
177
+ * [createTextEditorDecorationType](#window.createTextEditorDecorationType).
178
+ */
179
+ export interface TextEditorDecorationType {
180
+
181
+ /**
182
+ * Internal representation of the handle.
183
+ */
184
+ readonly key: string;
185
+
186
+ /**
187
+ * Remove this decoration type and all decorations on all text editors using it.
188
+ */
189
+ dispose(): void;
190
+ }
191
+
192
+ /**
193
+ * Represents different [reveal](#TextEditor.revealRange) strategies in a text editor.
194
+ */
195
+ export enum TextEditorRevealType {
196
+ /**
197
+ * The range will be revealed with as little scrolling as possible.
198
+ */
199
+ Default = 0,
200
+ /**
201
+ * The range will always be revealed in the center of the viewport.
202
+ */
203
+ InCenter = 1,
204
+ /**
205
+ * If the range is outside the viewport, it will be revealed in the center of the viewport.
206
+ * Otherwise, it will be revealed with as little scrolling as possible.
207
+ */
208
+ InCenterIfOutsideViewport = 2,
209
+ /**
210
+ * The range will always be revealed at the top of the viewport.
211
+ */
212
+ AtTop = 3
213
+ }
214
+
215
+ /**
216
+ * Represents different positions for rendering a decoration in an [overview ruler](#DecorationRenderOptions.overviewRulerLane).
217
+ * The overview ruler supports three lanes.
218
+ */
219
+ export enum OverviewRulerLane {
220
+ Left = 1,
221
+ Center = 2,
222
+ Right = 4,
223
+ Full = 7
224
+ }
225
+
226
+ /**
227
+ * Describes the behavior of decorations when typing/editing at their edges.
228
+ */
229
+ export enum DecorationRangeBehavior {
230
+ /**
231
+ * The decoration's range will widen when edits occur at the start or end.
232
+ */
233
+ OpenOpen = 0,
234
+ /**
235
+ * The decoration's range will not widen when edits occur at the start of end.
236
+ */
237
+ ClosedClosed = 1,
238
+ /**
239
+ * The decoration's range will widen when edits occur at the start, but not at the end.
240
+ */
241
+ OpenClosed = 2,
242
+ /**
243
+ * The decoration's range will widen when edits occur at the end, but not at the start.
244
+ */
245
+ ClosedOpen = 3
246
+ }
247
+
248
+ /**
249
+ * Represents options to configure the behavior of showing a [document](#TextDocument) in an [editor](#TextEditor).
250
+ */
251
+ export interface TextDocumentShowOptions {
252
+ /**
253
+ * An optional view column in which the [editor](#TextEditor) should be shown.
254
+ * The default is the [active](#ViewColumn.Active), other values are adjusted to
255
+ * be `Min(column, columnCount + 1)`, the [active](#ViewColumn.Active)-column is
256
+ * not adjusted. Use [`ViewColumn.Beside`](#ViewColumn.Beside) to open the
257
+ * editor to the side of the currently active one.
258
+ */
259
+ viewColumn?: ViewColumn;
260
+
261
+ /**
262
+ * An optional flag that when `true` will stop the [editor](#TextEditor) from taking focus.
263
+ */
264
+ preserveFocus?: boolean;
265
+
266
+ /**
267
+ * An optional flag that controls if an [editor](#TextEditor)-tab will be replaced
268
+ * with the next editor or if it will be kept.
269
+ */
270
+ preview?: boolean;
271
+
272
+ /**
273
+ * An optional selection to apply for the document in the [editor](#TextEditor).
274
+ */
275
+ selection?: Range;
276
+ }
277
+
278
+ /**
279
+ * Represents rendering styles for a [text editor decoration](#TextEditorDecorationType).
280
+ */
281
+ export interface DecorationRenderOptions extends ThemableDecorationRenderOptions {
282
+ /**
283
+ * Should the decoration be rendered also on the whitespace after the line text.
284
+ * Defaults to `false`.
285
+ */
286
+ isWholeLine?: boolean;
287
+
288
+ /**
289
+ * Customize the growing behavior of the decoration when edits occur at the edges of the decoration's range.
290
+ * Defaults to `DecorationRangeBehavior.OpenOpen`.
291
+ */
292
+ rangeBehavior?: DecorationRangeBehavior;
293
+
294
+ /**
295
+ * The position in the overview ruler where the decoration should be rendered.
296
+ */
297
+ overviewRulerLane?: OverviewRulerLane;
298
+
299
+ /**
300
+ * Overwrite options for light themes.
301
+ */
302
+ light?: ThemableDecorationRenderOptions;
303
+
304
+ /**
305
+ * Overwrite options for dark themes.
306
+ */
307
+ dark?: ThemableDecorationRenderOptions;
308
+ }
309
+
310
+ /**
311
+ * Represents options for a specific decoration in a [decoration set](#TextEditorDecorationType).
312
+ */
313
+ export interface DecorationOptions {
314
+
315
+ /**
316
+ * Range to which this decoration is applied. The range must not be empty.
317
+ */
318
+ range: Range;
319
+
320
+ /**
321
+ * A message that should be rendered when hovering over the decoration.
322
+ */
323
+ hoverMessage?: MarkedString | MarkedString[];
324
+
325
+ /**
326
+ * Render options applied to the current decoration. For performance reasons, keep the
327
+ * number of decoration specific options small, and use decoration types wherever possible.
328
+ */
329
+ renderOptions?: DecorationInstanceRenderOptions;
330
+ }
331
+
332
+ export interface ThemableDecorationInstanceRenderOptions {
333
+ /**
334
+ * Defines the rendering options of the attachment that is inserted before the decorated text.
335
+ */
336
+ before?: ThemableDecorationAttachmentRenderOptions;
337
+
338
+ /**
339
+ * Defines the rendering options of the attachment that is inserted after the decorated text.
340
+ */
341
+ after?: ThemableDecorationAttachmentRenderOptions;
342
+ }
343
+
344
+ export interface DecorationInstanceRenderOptions extends ThemableDecorationInstanceRenderOptions {
345
+ /**
346
+ * Overwrite options for light themes.
347
+ */
348
+ light?: ThemableDecorationInstanceRenderOptions;
349
+
350
+ /**
351
+ * Overwrite options for dark themes.
352
+ */
353
+ dark?: ThemableDecorationInstanceRenderOptions;
354
+ }
355
+
356
+ /**
357
+ * Represents an editor that is attached to a [document](#TextDocument).
358
+ */
359
+ export interface TextEditor {
360
+
361
+ /**
362
+ * The document associated with this text editor. The document will be the same for the entire lifetime of this text editor.
363
+ */
364
+ readonly document: TextDocument;
365
+
366
+ /**
367
+ * The primary selection on this text editor. Shorthand for `TextEditor.selections[0]`.
368
+ */
369
+ selection: Selection;
370
+
371
+ /**
372
+ * The selections in this text editor. The primary selection is always at index 0.
373
+ */
374
+ selections: Selection[];
375
+
376
+ /**
377
+ * The current visible ranges in the editor (vertically).
378
+ * This accounts only for vertical scrolling, and not for horizontal scrolling.
379
+ */
380
+ readonly visibleRanges: Range[];
381
+
382
+ /**
383
+ * Text editor options.
384
+ */
385
+ options: TextEditorOptions;
386
+
387
+ /**
388
+ * The column in which this editor shows. Will be `undefined` in case this
389
+ * isn't one of the main editors, e.g. an embedded editor, or when the editor
390
+ * column is larger than three.
391
+ */
392
+ viewColumn?: ViewColumn;
393
+
394
+ /**
395
+ * Perform an edit on the document associated with this text editor.
396
+ *
397
+ * The given callback-function is invoked with an [edit-builder](#TextEditorEdit) which must
398
+ * be used to make edits. Note that the edit-builder is only valid while the
399
+ * callback executes.
400
+ *
401
+ * @param callback A function which can create edits using an [edit-builder](#TextEditorEdit).
402
+ * @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
403
+ * @return A promise that resolves with a value indicating if the edits could be applied.
404
+ */
405
+ edit(callback: (editBuilder: TextEditorEdit) => void, options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable<boolean>;
406
+
407
+ /**
408
+ * Insert a [snippet](#SnippetString) and put the editor into snippet mode. "Snippet mode"
409
+ * means the editor adds placeholders and additional cursors so that the user can complete
410
+ * or accept the snippet.
411
+ *
412
+ * @param snippet The snippet to insert in this edit.
413
+ * @param location Position or range at which to insert the snippet, defaults to the current editor selection or selections.
414
+ * @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
415
+ * @return A promise that resolves with a value indicating if the snippet could be inserted. Note that the promise does not signal
416
+ * that the snippet is completely filled-in or accepted.
417
+ */
418
+ insertSnippet(snippet: SnippetString, location?: Position | Range | ReadonlyArray<Position> | ReadonlyArray<Range>, options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable<boolean>;
419
+
420
+ /**
421
+ * Adds a set of decorations to the text editor. If a set of decorations already exists with
422
+ * the given [decoration type](#TextEditorDecorationType), they will be replaced.
423
+ *
424
+ * @see [createTextEditorDecorationType](#window.createTextEditorDecorationType).
425
+ *
426
+ * @param decorationType A decoration type.
427
+ * @param rangesOrOptions Either [ranges](#Range) or more detailed [options](#DecorationOptions).
428
+ */
429
+ setDecorations(decorationType: TextEditorDecorationType, rangesOrOptions: Range[] | DecorationOptions[]): void;
430
+
431
+ /**
432
+ * Scroll as indicated by `revealType` in order to reveal the given range.
433
+ *
434
+ * @param range A range.
435
+ * @param revealType The scrolling strategy for revealing `range`.
436
+ */
437
+ revealRange(range: Range, revealType?: TextEditorRevealType): void;
438
+
439
+ /**
440
+ * ~~Show the text editor.~~
441
+ *
442
+ * @deprecated Use [window.showTextDocument](#window.showTextDocument) instead.
443
+ *
444
+ * @param column The [column](#ViewColumn) in which to show this editor.
445
+ * This method shows unexpected behavior and will be removed in the next major update.
446
+ */
447
+ show(column?: ViewColumn): void;
448
+
449
+ /**
450
+ * ~~Hide the text editor.~~
451
+ *
452
+ * @deprecated Use the command `workbench.action.closeActiveEditor` instead.
453
+ * This method shows unexpected behavior and will be removed in the next major update.
454
+ */
455
+ hide(): void;
456
+ }
457
+
458
+ export interface TextEditorEdit {
459
+ /**
460
+ * Replace a certain text region with a new value.
461
+ * You can use \r\n or \n in `value` and they will be normalized to the current [document](#TextDocument).
462
+ *
463
+ * @param location The range this operation should remove.
464
+ * @param value The new text this operation should insert after removing `location`.
465
+ */
466
+ replace(location: Position | Range | Selection, value: string): void;
467
+
468
+ /**
469
+ * Insert text at a location.
470
+ * You can use \r\n or \n in `value` and they will be normalized to the current [document](#TextDocument).
471
+ * Although the equivalent text edit can be made with [replace](#TextEditorEdit.replace), `insert` will produce a different resulting selection (it will get moved).
472
+ *
473
+ * @param location The position where the new text should be inserted.
474
+ * @param value The new text this operation should insert.
475
+ */
476
+ insert(location: Position, value: string): void;
477
+
478
+ /**
479
+ * Delete a certain text region.
480
+ *
481
+ * @param location The range this operation should remove.
482
+ */
483
+ delete(location: Range | Selection): void;
484
+
485
+ /**
486
+ * Set the end of line sequence.
487
+ *
488
+ * @param endOfLine The new end of line for the [document](#TextDocument).
489
+ */
490
+ setEndOfLine(endOfLine: EndOfLine): void;
491
+ }
492
+
493
+ /**
494
+ * Denotes a location of an editor in the window. Editors can be arranged in a grid
495
+ * and each column represents one editor location in that grid by counting the editors
496
+ * in order of their appearance.
497
+ */
498
+ export enum ViewColumn {
499
+ /**
500
+ * A *symbolic* editor column representing the currently active column. This value
501
+ * can be used when opening editors, but the *resolved* [viewColumn](#TextEditor.viewColumn)-value
502
+ * of editors will always be `One`, `Two`, `Three`,... or `undefined` but never `Active`.
503
+ */
504
+ Active = -1,
505
+ /**
506
+ * A *symbolic* editor column representing the column to the side of the active one. This value
507
+ * can be used when opening editors, but the *resolved* [viewColumn](#TextEditor.viewColumn)-value
508
+ * of editors will always be `One`, `Two`, `Three`,... or `undefined` but never `Beside`.
509
+ */
510
+ Beside = -2,
511
+ /**
512
+ * The first editor column.
513
+ */
514
+ One = 1,
515
+ /**
516
+ * The second editor column.
517
+ */
518
+ Two = 2,
519
+ /**
520
+ * The third editor column.
521
+ */
522
+ Three = 3,
523
+ /**
524
+ * The fourth editor column.
525
+ */
526
+ Four = 4,
527
+ /**
528
+ * The fifth editor column.
529
+ */
530
+ Five = 5,
531
+ /**
532
+ * The sixth editor column.
533
+ */
534
+ Six = 6,
535
+ /**
536
+ * The seventh editor column.
537
+ */
538
+ Seven = 7,
539
+ /**
540
+ * The eighth editor column.
541
+ */
542
+ Eight = 8,
543
+ /**
544
+ * The ninth editor column.
545
+ */
546
+ Nine = 9
547
+ }
548
+
549
+
550
+ export namespace window {
551
+
552
+ /**
553
+ * The currently active editor or `undefined`. The active editor is the one
554
+ * that currently has focus or, when none has focus, the one that has changed
555
+ * input most recently.
556
+ */
557
+ export let activeTextEditor: TextEditor | undefined;
558
+
559
+ /**
560
+ * The currently visible editors or an empty array.
561
+ */
562
+ export let visibleTextEditors: TextEditor[];
563
+
564
+ /**
565
+ * An [event](#Event) which fires when the [active editor](#window.activeTextEditor)
566
+ * has changed. *Note* that the event also fires when the active editor changes
567
+ * to `undefined`.
568
+ */
569
+ export const onDidChangeActiveTextEditor: Event<TextEditor | undefined>;
570
+
571
+ /**
572
+ * An [event](#Event) which fires when the array of [visible editors](#window.visibleTextEditors)
573
+ * has changed.
574
+ */
575
+ export const onDidChangeVisibleTextEditors: Event<TextEditor[]>;
576
+
577
+ /**
578
+ * An [event](#Event) which fires when the selection in an editor has changed.
579
+ */
580
+ export const onDidChangeTextEditorSelection: Event<TextEditorSelectionChangeEvent>;
581
+
582
+ /**
583
+ * An [event](#Event) which fires when the visible ranges of an editor has changed.
584
+ */
585
+ export const onDidChangeTextEditorVisibleRanges: Event<TextEditorVisibleRangesChangeEvent>;
586
+
587
+ /**
588
+ * An [event](#Event) which fires when the options of an editor have changed.
589
+ */
590
+ export const onDidChangeTextEditorOptions: Event<TextEditorOptionsChangeEvent>;
591
+
592
+ /**
593
+ * An [event](#Event) which fires when the view column of an editor has changed.
594
+ */
595
+ export const onDidChangeTextEditorViewColumn: Event<TextEditorViewColumnChangeEvent>;
596
+
597
+
598
+ /**
599
+ * Show the given document in a text editor. A [column](#ViewColumn) can be provided
600
+ * to control where the editor is being shown. Might change the [active editor](#window.activeTextEditor).
601
+ *
602
+ * @param document A text document to be shown.
603
+ * @param column A view column in which the [editor](#TextEditor) should be shown. The default is the [active](#ViewColumn.Active), other values
604
+ * are adjusted to be `Min(column, columnCount + 1)`, the [active](#ViewColumn.Active)-column is not adjusted. Use [`ViewColumn.Beside`](#ViewColumn.Beside)
605
+ * to open the editor to the side of the currently active one.
606
+ * @param preserveFocus When `true` the editor will not take focus.
607
+ * @return A promise that resolves to an [editor](#TextEditor).
608
+ */
609
+ export function showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): Thenable<TextEditor>;
610
+
611
+ /**
612
+ * Show the given document in a text editor. [Options](#TextDocumentShowOptions) can be provided
613
+ * to control options of the editor is being shown. Might change the [active editor](#window.activeTextEditor).
614
+ *
615
+ * @param document A text document to be shown.
616
+ * @param options [Editor options](#TextDocumentShowOptions) to configure the behavior of showing the [editor](#TextEditor).
617
+ * @return A promise that resolves to an [editor](#TextEditor).
618
+ */
619
+ export function showTextDocument(document: TextDocument, options?: TextDocumentShowOptions): Thenable<TextEditor>;
620
+
621
+ /**
622
+ * A short-hand for `openTextDocument(uri).then(document => showTextDocument(document, options))`.
623
+ *
624
+ * @see [openTextDocument](#openTextDocument)
625
+ *
626
+ * @param uri A resource identifier.
627
+ * @param options [Editor options](#TextDocumentShowOptions) to configure the behavior of showing the [editor](#TextEditor).
628
+ * @return A promise that resolves to an [editor](#TextEditor).
629
+ */
630
+ export function showTextDocument(uri: Uri, options?: TextDocumentShowOptions): Thenable<TextEditor>;
631
+
632
+ /**
633
+ * Create a TextEditorDecorationType that can be used to add decorations to text editors.
634
+ *
635
+ * @param options Rendering options for the decoration type.
636
+ * @return A new decoration type instance.
637
+ */
638
+ export function createTextEditorDecorationType(options: DecorationRenderOptions): TextEditorDecorationType;
639
+
640
+ }
641
+
642
+ export class TextEdit {
643
+
644
+ /**
645
+ * Utility to create a replace edit.
646
+ *
647
+ * @param range A range.
648
+ * @param newText A string.
649
+ * @return A new text edit object.
650
+ */
651
+ static replace(range: Range, newText: string): TextEdit;
652
+
653
+ /**
654
+ * Utility to create an insert edit.
655
+ *
656
+ * @param position A position, will become an empty range.
657
+ * @param newText A string.
658
+ * @return A new text edit object.
659
+ */
660
+ static insert(position: Position, newText: string): TextEdit;
661
+
662
+ /**
663
+ * Utility to create a delete edit.
664
+ *
665
+ * @param range A range.
666
+ * @return A new text edit object.
667
+ */
668
+ static delete(range: Range): TextEdit;
669
+
670
+ /**
671
+ * Utility to create an eol-edit.
672
+ *
673
+ * @param eol An eol-sequence
674
+ * @return A new text edit object.
675
+ */
676
+ static setEndOfLine(eol: EndOfLine): TextEdit;
677
+
678
+ /**
679
+ * The range this edit applies to.
680
+ */
681
+ range: Range;
682
+
683
+ /**
684
+ * The string this edit will insert.
685
+ */
686
+ newText: string;
687
+
688
+ /**
689
+ * The eol-sequence used in the document.
690
+ *
691
+ * *Note* that the eol-sequence will be applied to the
692
+ * whole document.
693
+ */
694
+ newEol: EndOfLine;
695
+
696
+ /**
697
+ * Create a new TextEdit.
698
+ *
699
+ * @param range A range.
700
+ * @param newText A string.
701
+ */
702
+ constructor(range: Range, newText: string);
703
+ }
704
+
705
+ /**
706
+ * Provider for text based custom editors.
707
+ *
708
+ * Text based custom editors use a [`TextDocument`](#TextDocument) as their data model. This considerably simplifies
709
+ * implementing a custom editor as it allows VS Code to handle many common operations such as
710
+ * undo and backup. The provider is responsible for synchronizing text changes between the webview and the `TextDocument`.
711
+ */
712
+ export interface CustomTextEditorProvider {
713
+
714
+ /**
715
+ * Resolve a custom editor for a given text resource.
716
+ *
717
+ * This is called when a user first opens a resource for a `CustomTextEditorProvider`, or if they reopen an
718
+ * existing editor using this `CustomTextEditorProvider`.
719
+ *
720
+ *
721
+ * @param document Document for the resource to resolve.
722
+ *
723
+ * @param webviewPanel The webview panel used to display the editor UI for this resource.
724
+ *
725
+ * During resolve, the provider must fill in the initial html for the content webview panel and hook up all
726
+ * the event listeners on it that it is interested in. The provider can also hold onto the `WebviewPanel` to
727
+ * use later for example in a command. See [`WebviewPanel`](#WebviewPanel) for additional details.
728
+ *
729
+ * @param token A cancellation token that indicates the result is no longer needed.
730
+ *
731
+ * @return Thenable indicating that the custom editor has been resolved.
732
+ */
733
+ resolveCustomTextEditor(document: TextDocument, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
734
+ }
735
+
736
+ /**
737
+ * Represents a custom document used by a [`CustomEditorProvider`](#CustomEditorProvider).
738
+ *
739
+ * Custom documents are only used within a given `CustomEditorProvider`. The lifecycle of a `CustomDocument` is
740
+ * managed by VS Code. When no more references remain to a `CustomDocument`, it is disposed of.
741
+ */
742
+ interface CustomDocument {
743
+ /**
744
+ * The associated uri for this document.
745
+ */
746
+ readonly uri: Uri;
747
+
748
+ /**
749
+ * Dispose of the custom document.
750
+ *
751
+ * This is invoked by VS Code when there are no more references to a given `CustomDocument` (for example when
752
+ * all editors associated with the document have been closed.)
753
+ */
754
+ dispose(): void;
755
+ }
756
+
757
+ /**
758
+ * Event triggered by extensions to signal to VS Code that an edit has occurred on an [`CustomDocument`](#CustomDocument).
759
+ *
760
+ * @see [`CustomDocumentProvider.onDidChangeCustomDocument`](#CustomDocumentProvider.onDidChangeCustomDocument).
761
+ */
762
+ interface CustomDocumentEditEvent<T extends CustomDocument = CustomDocument> {
763
+
764
+ /**
765
+ * The document that the edit is for.
766
+ */
767
+ readonly document: T;
768
+
769
+ /**
770
+ * Undo the edit operation.
771
+ *
772
+ * This is invoked by VS Code when the user undoes this edit. To implement `undo`, your
773
+ * extension should restore the document and editor to the state they were in just before this
774
+ * edit was added to VS Code's internal edit stack by `onDidChangeCustomDocument`.
775
+ */
776
+ undo(): Thenable<void> | void;
777
+
778
+ /**
779
+ * Redo the edit operation.
780
+ *
781
+ * This is invoked by VS Code when the user redoes this edit. To implement `redo`, your
782
+ * extension should restore the document and editor to the state they were in just after this
783
+ * edit was added to VS Code's internal edit stack by `onDidChangeCustomDocument`.
784
+ */
785
+ redo(): Thenable<void> | void;
786
+
787
+ /**
788
+ * Display name describing the edit.
789
+ *
790
+ * This will be shown to users in the UI for undo/redo operations.
791
+ */
792
+ readonly label?: string;
793
+ }
794
+
795
+ /**
796
+ * Event triggered by extensions to signal to VS Code that the content of a [`CustomDocument`](#CustomDocument)
797
+ * has changed.
798
+ *
799
+ * @see [`CustomDocumentProvider.onDidChangeCustomDocument`](#CustomDocumentProvider.onDidChangeCustomDocument).
800
+ */
801
+ interface CustomDocumentContentChangeEvent<T extends CustomDocument = CustomDocument> {
802
+ /**
803
+ * The document that the change is for.
804
+ */
805
+ readonly document: T;
806
+ }
807
+
808
+ /**
809
+ * A backup for an [`CustomDocument`](#CustomDocument).
810
+ */
811
+ interface CustomDocumentBackup {
812
+ /**
813
+ * Unique identifier for the backup.
814
+ *
815
+ * This id is passed back to your extension in `openCustomDocument` when opening a custom editor from a backup.
816
+ */
817
+ readonly id: string;
818
+
819
+ /**
820
+ * Delete the current backup.
821
+ *
822
+ * This is called by VS Code when it is clear the current backup is no longer needed, such as when a new backup
823
+ * is made or when the file is saved.
824
+ */
825
+ delete(): void;
826
+ }
827
+
828
+ /**
829
+ * Additional information used to implement [`CustomEditableDocument.backup`](#CustomEditableDocument.backup).
830
+ */
831
+ interface CustomDocumentBackupContext {
832
+ /**
833
+ * Suggested file location to write the new backup.
834
+ *
835
+ * Note that your extension is free to ignore this and use its own strategy for backup.
836
+ *
837
+ * If the editor is for a resource from the current workspace, `destination` will point to a file inside
838
+ * `ExtensionContext.storagePath`. The parent folder of `destination` may not exist, so make sure to created it
839
+ * before writing the backup to this location.
840
+ */
841
+ readonly destination: Uri;
842
+ }
843
+
844
+ /**
845
+ * Additional information about the opening custom document.
846
+ */
847
+ interface CustomDocumentOpenContext {
848
+ /**
849
+ * The id of the backup to restore the document from or `undefined` if there is no backup.
850
+ *
851
+ * If this is provided, your extension should restore the editor from the backup instead of reading the file
852
+ * from the user's workspace.
853
+ */
854
+ readonly backupId?: string;
855
+
856
+ untitledDocumentData?: Uint8Array;
857
+ }
858
+
859
+ /**
860
+ * Provider for readonly custom editors that use a custom document model.
861
+ *
862
+ * Custom editors use [`CustomDocument`](#CustomDocument) as their document model instead of a [`TextDocument`](#TextDocument).
863
+ *
864
+ * You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple
865
+ * text based documents, use [`CustomTextEditorProvider`](#CustomTextEditorProvider) instead.
866
+ *
867
+ * @param T Type of the custom document returned by this provider.
868
+ */
869
+ export interface CustomReadonlyEditorProvider<T extends CustomDocument = CustomDocument> {
870
+
871
+ /**
872
+ * Create a new document for a given resource.
873
+ *
874
+ * `openCustomDocument` is called when the first time an editor for a given resource is opened. The opened
875
+ * document is then passed to `resolveCustomEditor` so that the editor can be shown to the user.
876
+ *
877
+ * Already opened `CustomDocument` are re-used if the user opened additional editors. When all editors for a
878
+ * given resource are closed, the `CustomDocument` is disposed of. Opening an editor at this point will
879
+ * trigger another call to `openCustomDocument`.
880
+ *
881
+ * @param uri Uri of the document to open.
882
+ * @param openContext Additional information about the opening custom document.
883
+ * @param token A cancellation token that indicates the result is no longer needed.
884
+ *
885
+ * @return The custom document.
886
+ */
887
+ openCustomDocument(uri: Uri, openContext: CustomDocumentOpenContext, token: CancellationToken): Thenable<T> | T;
888
+
889
+ /**
890
+ * Resolve a custom editor for a given resource.
891
+ *
892
+ * This is called whenever the user opens a new editor for this `CustomEditorProvider`.
893
+ *
894
+ * @param document Document for the resource being resolved.
895
+ *
896
+ * @param webviewPanel The webview panel used to display the editor UI for this resource.
897
+ *
898
+ * During resolve, the provider must fill in the initial html for the content webview panel and hook up all
899
+ * the event listeners on it that it is interested in. The provider can also hold onto the `WebviewPanel` to
900
+ * use later for example in a command. See [`WebviewPanel`](#WebviewPanel) for additional details.
901
+ *
902
+ * @param token A cancellation token that indicates the result is no longer needed.
903
+ *
904
+ * @return Optional thenable indicating that the custom editor has been resolved.
905
+ */
906
+ resolveCustomEditor(document: T, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
907
+ }
908
+
909
+ /**
910
+ * Provider for editable custom editors that use a custom document model.
911
+ *
912
+ * Custom editors use [`CustomDocument`](#CustomDocument) as their document model instead of a [`TextDocument`](#TextDocument).
913
+ * This gives extensions full control over actions such as edit, save, and backup.
914
+ *
915
+ * You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple
916
+ * text based documents, use [`CustomTextEditorProvider`](#CustomTextEditorProvider) instead.
917
+ *
918
+ * @param T Type of the custom document returned by this provider.
919
+ */
920
+ export interface CustomEditorProvider<T extends CustomDocument = CustomDocument> extends CustomReadonlyEditorProvider<T> {
921
+ /**
922
+ * Signal that an edit has occurred inside a custom editor.
923
+ *
924
+ * This event must be fired by your extension whenever an edit happens in a custom editor. An edit can be
925
+ * anything from changing some text, to cropping an image, to reordering a list. Your extension is free to
926
+ * define what an edit is and what data is stored on each edit.
927
+ *
928
+ * Firing `onDidChange` causes VS Code to mark the editors as being dirty. This is cleared when the user either
929
+ * saves or reverts the file.
930
+ *
931
+ * Editors that support undo/redo must fire a `CustomDocumentEditEvent` whenever an edit happens. This allows
932
+ * users to undo and redo the edit using VS Code's standard VS Code keyboard shortcuts. VS Code will also mark
933
+ * the editor as no longer being dirty if the user undoes all edits to the last saved state.
934
+ *
935
+ * Editors that support editing but cannot use VS Code's standard undo/redo mechanism must fire a `CustomDocumentContentChangeEvent`.
936
+ * The only way for a user to clear the dirty state of an editor that does not support undo/redo is to either
937
+ * `save` or `revert` the file.
938
+ *
939
+ * An editor should only ever fire `CustomDocumentEditEvent` events, or only ever fire `CustomDocumentContentChangeEvent` events.
940
+ */
941
+ readonly onDidChangeCustomDocument: Event<CustomDocumentEditEvent<T>> | Event<CustomDocumentContentChangeEvent<T>>;
942
+
943
+ /**
944
+ * Save a custom document.
945
+ *
946
+ * This method is invoked by VS Code when the user saves a custom editor. This can happen when the user
947
+ * triggers save while the custom editor is active, by commands such as `save all`, or by auto save if enabled.
948
+ *
949
+ * To implement `save`, the implementer must persist the custom editor. This usually means writing the
950
+ * file data for the custom document to disk. After `save` completes, any associated editor instances will
951
+ * no longer be marked as dirty.
952
+ *
953
+ * @param document Document to save.
954
+ * @param cancellation Token that signals the save is no longer required (for example, if another save was triggered).
955
+ *
956
+ * @return Thenable signaling that saving has completed.
957
+ */
958
+ saveCustomDocument(document: T, cancellation: CancellationToken): Thenable<void>;
959
+
960
+ /**
961
+ * Save a custom document to a different location.
962
+ *
963
+ * This method is invoked by VS Code when the user triggers 'save as' on a custom editor. The implementer must
964
+ * persist the custom editor to `destination`.
965
+ *
966
+ * When the user accepts save as, the current editor is be replaced by an non-dirty editor for the newly saved file.
967
+ *
968
+ * @param document Document to save.
969
+ * @param destination Location to save to.
970
+ * @param cancellation Token that signals the save is no longer required.
971
+ *
972
+ * @return Thenable signaling that saving has completed.
973
+ */
974
+ saveCustomDocumentAs(document: T, destination: Uri, cancellation: CancellationToken): Thenable<void>;
975
+
976
+ /**
977
+ * Revert a custom document to its last saved state.
978
+ *
979
+ * This method is invoked by VS Code when the user triggers `File: Revert File` in a custom editor. (Note that
980
+ * this is only used using VS Code's `File: Revert File` command and not on a `git revert` of the file).
981
+ *
982
+ * To implement `revert`, the implementer must make sure all editor instances (webviews) for `document`
983
+ * are displaying the document in the same state is saved in. This usually means reloading the file from the
984
+ * workspace.
985
+ *
986
+ * @param document Document to revert.
987
+ * @param cancellation Token that signals the revert is no longer required.
988
+ *
989
+ * @return Thenable signaling that the change has completed.
990
+ */
991
+ revertCustomDocument(document: T, cancellation: CancellationToken): Thenable<void>;
992
+
993
+ /**
994
+ * Back up a dirty custom document.
995
+ *
996
+ * Backups are used for hot exit and to prevent data loss. Your `backup` method should persist the resource in
997
+ * its current state, i.e. with the edits applied. Most commonly this means saving the resource to disk in
998
+ * the `ExtensionContext.storagePath`. When VS Code reloads and your custom editor is opened for a resource,
999
+ * your extension should first check to see if any backups exist for the resource. If there is a backup, your
1000
+ * extension should load the file contents from there instead of from the resource in the workspace.
1001
+ *
1002
+ * `backup` is triggered approximately one second after the the user stops editing the document. If the user
1003
+ * rapidly edits the document, `backup` will not be invoked until the editing stops.
1004
+ *
1005
+ * `backup` is not invoked when `auto save` is enabled (since auto save already persists the resource).
1006
+ *
1007
+ * @param document Document to backup.
1008
+ * @param context Information that can be used to backup the document.
1009
+ * @param cancellation Token that signals the current backup since a new backup is coming in. It is up to your
1010
+ * extension to decided how to respond to cancellation. If for example your extension is backing up a large file
1011
+ * in an operation that takes time to complete, your extension may decide to finish the ongoing backup rather
1012
+ * than cancelling it to ensure that VS Code has some valid backup.
1013
+ */
1014
+ backupCustomDocument(document: T, context: CustomDocumentBackupContext, cancellation: CancellationToken): Thenable<CustomDocumentBackup>;
1015
+ }
1016
+
1017
+ }