@codingame/monaco-vscode-api 1.78.2 → 1.78.3-next.1

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 (136) hide show
  1. package/dist/api2.js +69 -4
  2. package/dist/coffeescript.js +2 -9
  3. package/dist/cpp.js +2 -16
  4. package/dist/csharp.js +2 -9
  5. package/dist/default-extensions/bat.js +3 -5
  6. package/dist/default-extensions/clojure.js +4 -6
  7. package/dist/default-extensions/coffeescript.js +3 -5
  8. package/dist/default-extensions/cpp.js +3 -7
  9. package/dist/default-extensions/csharp.js +3 -5
  10. package/dist/default-extensions/css.js +4 -6
  11. package/dist/default-extensions/dart.js +4 -6
  12. package/dist/default-extensions/diff.js +4 -6
  13. package/dist/default-extensions/docker.js +4 -6
  14. package/dist/default-extensions/fsharp.js +3 -5
  15. package/dist/default-extensions/go.js +4 -6
  16. package/dist/default-extensions/groovy.js +3 -5
  17. package/dist/default-extensions/handlebars.js +4 -6
  18. package/dist/default-extensions/hlsl.js +4 -6
  19. package/dist/default-extensions/html.js +3 -5
  20. package/dist/default-extensions/ini.js +4 -7
  21. package/dist/default-extensions/java.js +3 -5
  22. package/dist/default-extensions/javascript.js +4 -8
  23. package/dist/default-extensions/json.js +4 -7
  24. package/dist/default-extensions/julia.js +4 -6
  25. package/dist/default-extensions/latex.js +6 -5
  26. package/dist/default-extensions/less.js +4 -6
  27. package/dist/default-extensions/log.js +2 -4
  28. package/dist/default-extensions/lua.js +4 -6
  29. package/dist/default-extensions/make.js +4 -6
  30. package/dist/default-extensions/markdown-basics.js +3 -5
  31. package/dist/default-extensions/objective-c.js +4 -7
  32. package/dist/default-extensions/perl.js +5 -7
  33. package/dist/default-extensions/php.js +3 -5
  34. package/dist/default-extensions/powershell.js +4 -6
  35. package/dist/default-extensions/pug.js +4 -6
  36. package/dist/default-extensions/python.js +4 -6
  37. package/dist/default-extensions/r.js +4 -6
  38. package/dist/default-extensions/razor.js +4 -6
  39. package/dist/default-extensions/ruby.js +4 -6
  40. package/dist/default-extensions/rust.js +4 -6
  41. package/dist/default-extensions/scss.js +4 -6
  42. package/dist/default-extensions/shaderlab.js +4 -6
  43. package/dist/default-extensions/shellscript.js +4 -6
  44. package/dist/default-extensions/sql.js +4 -6
  45. package/dist/default-extensions/swift.js +3 -5
  46. package/dist/default-extensions/theme-abyss.js +2 -4
  47. package/dist/default-extensions/theme-defaults.js +2 -4
  48. package/dist/default-extensions/theme-kimbie-dark.js +2 -4
  49. package/dist/default-extensions/theme-monokai-dimmed.js +2 -4
  50. package/dist/default-extensions/theme-monokai.js +2 -4
  51. package/dist/default-extensions/theme-quietlight.js +2 -4
  52. package/dist/default-extensions/theme-red.js +2 -4
  53. package/dist/default-extensions/theme-seti.js +2 -4
  54. package/dist/default-extensions/theme-solarized-dark.js +2 -4
  55. package/dist/default-extensions/theme-solarized-light.js +2 -4
  56. package/dist/default-extensions/theme-tomorrow-night-blue.js +2 -4
  57. package/dist/default-extensions/typescript-basics.js +3 -7
  58. package/dist/default-extensions/typescript-language-features.js +7 -0
  59. package/dist/default-extensions/vb.js +3 -5
  60. package/dist/default-extensions/xml.js +5 -7
  61. package/dist/default-extensions/yaml.js +3 -7
  62. package/dist/extensions.d.ts +9 -2
  63. package/dist/fsharp.js +2 -9
  64. package/dist/groovy.js +2 -9
  65. package/dist/html.js +2 -10
  66. package/dist/java.js +2 -9
  67. package/dist/javascript.js +2 -14
  68. package/dist/latex-cpp-embedded-language-configuration.js +2 -0
  69. package/dist/latex-language-configuration.js +2 -0
  70. package/dist/markdown-latex-combined-language-configuration.js +2 -0
  71. package/dist/modelEditor.d.ts +136 -1398
  72. package/dist/monaco.d.ts +9 -5
  73. package/dist/monaco.js +370 -44
  74. package/dist/php.js +2 -10
  75. package/dist/polyfill.js +29 -10
  76. package/dist/rollup-vsix-plugin.d.ts +4 -2
  77. package/dist/rollup-vsix-plugin.js +903 -27
  78. package/dist/swift.js +2 -9
  79. package/dist/vb.js +2 -9
  80. package/package.json +3 -3
  81. package/dist/bat.js +0 -9
  82. package/dist/clojure.js +0 -8
  83. package/dist/coffeescript2.js +0 -2
  84. package/dist/cpp2.js +0 -2
  85. package/dist/csharp2.js +0 -2
  86. package/dist/css.js +0 -8
  87. package/dist/dart.js +0 -8
  88. package/dist/diff.js +0 -8
  89. package/dist/docker.js +0 -8
  90. package/dist/fsharp2.js +0 -2
  91. package/dist/go.js +0 -8
  92. package/dist/groovy2.js +0 -2
  93. package/dist/handlebars.js +0 -8
  94. package/dist/hlsl.js +0 -8
  95. package/dist/html2.js +0 -2
  96. package/dist/ini.js +0 -10
  97. package/dist/java2.js +0 -2
  98. package/dist/javascript2.js +0 -2
  99. package/dist/json.js +0 -10
  100. package/dist/julia.js +0 -8
  101. package/dist/latex.js +0 -11
  102. package/dist/less.js +0 -8
  103. package/dist/log.js +0 -7
  104. package/dist/lua.js +0 -8
  105. package/dist/make.js +0 -8
  106. package/dist/markdown-basics.js +0 -9
  107. package/dist/objective-c.js +0 -10
  108. package/dist/perl.js +0 -10
  109. package/dist/php2.js +0 -2
  110. package/dist/powershell.js +0 -8
  111. package/dist/pug.js +0 -8
  112. package/dist/python.js +0 -9
  113. package/dist/r.js +0 -8
  114. package/dist/razor.js +0 -8
  115. package/dist/ruby.js +0 -8
  116. package/dist/rust.js +0 -8
  117. package/dist/scss.js +0 -9
  118. package/dist/shaderlab.js +0 -8
  119. package/dist/shellscript.js +0 -8
  120. package/dist/sql.js +0 -8
  121. package/dist/swift2.js +0 -2
  122. package/dist/theme-abyss.js +0 -7
  123. package/dist/theme-defaults.js +0 -15
  124. package/dist/theme-kimbie-dark.js +0 -7
  125. package/dist/theme-monokai-dimmed.js +0 -7
  126. package/dist/theme-monokai.js +0 -7
  127. package/dist/theme-quietlight.js +0 -7
  128. package/dist/theme-red.js +0 -7
  129. package/dist/theme-seti.js +0 -7
  130. package/dist/theme-solarized-dark.js +0 -7
  131. package/dist/theme-solarized-light.js +0 -7
  132. package/dist/theme-tomorrow-night-blue.js +0 -7
  133. package/dist/typescript-basics.js +0 -14
  134. package/dist/vb2.js +0 -2
  135. package/dist/xml.js +0 -10
  136. package/dist/yaml.js +0 -10
@@ -48,27 +48,6 @@ interface IReference<T> extends IDisposable {
48
48
  readonly object: T;
49
49
  }
50
50
 
51
- interface CancellationToken {
52
- /**
53
- * A flag signalling is cancellation has been requested.
54
- */
55
- readonly isCancellationRequested: boolean;
56
- /**
57
- * An event which fires when cancellation is requested. This event
58
- * only ever fires `once` as cancellation can only happen once. Listeners
59
- * that are registered after cancellation will be called (next event loop run),
60
- * but also only once.
61
- *
62
- * @event
63
- */
64
- readonly onCancellationRequested: (listener: (e: any) => any, thisArgs?: any, disposables?: IDisposable[]) => IDisposable;
65
- }
66
- declare namespace CancellationToken {
67
- function isCancellationToken(thing: unknown): thing is CancellationToken;
68
- const None: Readonly<CancellationToken>;
69
- const Cancelled: Readonly<CancellationToken>;
70
- }
71
-
72
51
  interface IObservable<T, TChange = void> {
73
52
  readonly TChange: TChange;
74
53
  /**
@@ -368,1457 +347,216 @@ declare namespace Event {
368
347
  }
369
348
 
370
349
  /**
371
- * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
372
- * This class is a simple parser which creates the basic component parts
373
- * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
374
- * and encoding.
375
- *
376
- * ```txt
377
- * foo://example.com:8042/over/there?name=ferret#nose
378
- * \_/ \______________/\_________/ \_________/ \__/
379
- * | | | | |
380
- * scheme authority path query fragment
381
- * | _____________________|__
382
- * / \ / \
383
- * urn:example:animal:ferret:nose
384
- * ```
350
+ * Text snapshot that works like an iterator.
351
+ * Will try to return chunks of roughly ~64KB size.
352
+ * Will return null when finished.
385
353
  */
386
- declare class URI implements UriComponents {
387
- static isUri(thing: any): thing is URI;
388
- /**
389
- * scheme is the 'http' part of 'http://www.example.com/some/path?query#fragment'.
390
- * The part before the first colon.
391
- */
392
- readonly scheme: string;
393
- /**
394
- * authority is the 'www.example.com' part of 'http://www.example.com/some/path?query#fragment'.
395
- * The part between the first double slashes and the next slash.
396
- */
397
- readonly authority: string;
398
- /**
399
- * path is the '/some/path' part of 'http://www.example.com/some/path?query#fragment'.
400
- */
401
- readonly path: string;
402
- /**
403
- * query is the 'query' part of 'http://www.example.com/some/path?query#fragment'.
404
- */
405
- readonly query: string;
406
- /**
407
- * fragment is the 'fragment' part of 'http://www.example.com/some/path?query#fragment'.
408
- */
409
- readonly fragment: string;
410
- /**
411
- * @internal
412
- */
413
- protected constructor(scheme: string, authority?: string, path?: string, query?: string, fragment?: string, _strict?: boolean);
414
- /**
415
- * @internal
416
- */
417
- protected constructor(components: UriComponents);
418
- /**
419
- * Returns a string representing the corresponding file system path of this URI.
420
- * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
421
- * platform specific path separator.
422
- *
423
- * * Will *not* validate the path for invalid characters and semantics.
424
- * * Will *not* look at the scheme of this URI.
425
- * * The result shall *not* be used for display purposes but for accessing a file on disk.
426
- *
427
- *
428
- * The *difference* to `URI#path` is the use of the platform specific separator and the handling
429
- * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
430
- *
431
- * ```ts
432
- const u = URI.parse('file://server/c$/folder/file.txt')
433
- u.authority === 'server'
434
- u.path === '/shares/c$/file.txt'
435
- u.fsPath === '\\server\c$\folder\file.txt'
436
- ```
437
- *
438
- * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
439
- * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
440
- * with URIs that represent files on disk (`file` scheme).
441
- */
442
- get fsPath(): string;
443
- with(change: {
444
- scheme?: string;
445
- authority?: string | null;
446
- path?: string | null;
447
- query?: string | null;
448
- fragment?: string | null;
449
- }): URI;
450
- /**
451
- * Creates a new URI from a string, e.g. `http://www.example.com/some/path`,
452
- * `file:///usr/home`, or `scheme:with/path`.
453
- *
454
- * @param value A string which represents an URI (see `URI#toString`).
455
- */
456
- static parse(value: string, _strict?: boolean): URI;
457
- /**
458
- * Creates a new URI from a file system path, e.g. `c:\my\files`,
459
- * `/usr/home`, or `\\server\share\some\path`.
460
- *
461
- * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
462
- * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
463
- * `URI.parse('file://' + path)` because the path might contain characters that are
464
- * interpreted (# and ?). See the following sample:
465
- * ```ts
466
- const good = URI.file('/coding/c#/project1');
467
- good.scheme === 'file';
468
- good.path === '/coding/c#/project1';
469
- good.fragment === '';
470
- const bad = URI.parse('file://' + '/coding/c#/project1');
471
- bad.scheme === 'file';
472
- bad.path === '/coding/c'; // path is now broken
473
- bad.fragment === '/project1';
474
- ```
475
- *
476
- * @param path A file system path (see `URI#fsPath`)
477
- */
478
- static file(path: string): URI;
479
- static from(components: {
480
- scheme: string;
481
- authority?: string;
482
- path?: string;
483
- query?: string;
484
- fragment?: string;
485
- }): URI;
486
- /**
487
- * Join a URI path with path fragments and normalizes the resulting path.
488
- *
489
- * @param uri The input URI.
490
- * @param pathFragment The path fragment to add to the URI path.
491
- * @returns The resulting URI.
492
- */
493
- static joinPath(uri: URI, ...pathFragment: string[]): URI;
494
- /**
495
- * Creates a string representation for this URI. It's guaranteed that calling
496
- * `URI.parse` with the result of this function creates an URI which is equal
497
- * to this URI.
498
- *
499
- * * The result shall *not* be used for display purposes but for externalization or transport.
500
- * * The result will be encoded using the percentage encoding and encoding happens mostly
501
- * ignore the scheme-specific encoding rules.
502
- *
503
- * @param skipEncoding Do not encode the result, default is `false`
504
- */
505
- toString(skipEncoding?: boolean): string;
506
- toJSON(): UriComponents;
507
- static revive(data: UriComponents | URI): URI;
508
- static revive(data: UriComponents | URI | undefined): URI | undefined;
509
- static revive(data: UriComponents | URI | null): URI | null;
510
- static revive(data: UriComponents | URI | undefined | null): URI | undefined | null;
511
- }
512
- interface UriComponents {
513
- scheme: string;
514
- authority: string;
515
- path: string;
516
- query: string;
517
- fragment: string;
354
+ interface ITextSnapshot {
355
+ read(): string | null;
518
356
  }
519
-
520
357
  /**
521
- * A position in the editor. This interface is suitable for serialization.
358
+ * A model.
522
359
  */
523
- interface IPosition {
524
- /**
525
- * line number (starts at 1)
526
- */
527
- readonly lineNumber: number;
528
- /**
529
- * column (the first character in a line is between column 1 and column 2)
530
- */
531
- readonly column: number;
532
- }
360
+ type ITextModel = monaco.editor.ITextModel
361
+
533
362
  /**
534
- * A position in the editor.
363
+ * A rich code editor.
535
364
  */
536
- declare class Position {
537
- /**
538
- * line number (starts at 1)
539
- */
540
- readonly lineNumber: number;
541
- /**
542
- * column (the first character in a line is between column 1 and column 2)
543
- */
544
- readonly column: number;
545
- constructor(lineNumber: number, column: number);
546
- /**
547
- * Create a new position from this position.
548
- *
549
- * @param newLineNumber new line number
550
- * @param newColumn new column
551
- */
552
- with(newLineNumber?: number, newColumn?: number): Position;
553
- /**
554
- * Derive a new position from this position.
555
- *
556
- * @param deltaLineNumber line number delta
557
- * @param deltaColumn column delta
558
- */
559
- delta(deltaLineNumber?: number, deltaColumn?: number): Position;
560
- /**
561
- * Test if this position equals other position
562
- */
563
- equals(other: IPosition): boolean;
564
- /**
565
- * Test if position `a` equals position `b`
566
- */
567
- static equals(a: IPosition | null, b: IPosition | null): boolean;
568
- /**
569
- * Test if this position is before other position.
570
- * If the two positions are equal, the result will be false.
571
- */
572
- isBefore(other: IPosition): boolean;
573
- /**
574
- * Test if position `a` is before position `b`.
575
- * If the two positions are equal, the result will be false.
576
- */
577
- static isBefore(a: IPosition, b: IPosition): boolean;
578
- /**
579
- * Test if this position is before other position.
580
- * If the two positions are equal, the result will be true.
581
- */
582
- isBeforeOrEqual(other: IPosition): boolean;
583
- /**
584
- * Test if position `a` is before position `b`.
585
- * If the two positions are equal, the result will be true.
586
- */
587
- static isBeforeOrEqual(a: IPosition, b: IPosition): boolean;
365
+ type ICodeEditor = monaco.editor.ICodeEditor
366
+
367
+ interface IEditorModel {
588
368
  /**
589
- * A function that compares positions, useful for sorting
369
+ * Emitted when the model is about to be disposed.
590
370
  */
591
- static compare(a: IPosition, b: IPosition): number;
371
+ readonly onWillDispose: Event<void>;
592
372
  /**
593
- * Clone this position.
373
+ * Resolves the model.
594
374
  */
595
- clone(): Position;
375
+ resolve(): Promise<void>;
596
376
  /**
597
- * Convert to a human-readable representation.
377
+ * Find out if the editor model was resolved or not.
598
378
  */
599
- toString(): string;
379
+ isResolved(): boolean;
600
380
  /**
601
- * Create a `Position` from an `IPosition`.
381
+ * Find out if this model has been disposed.
602
382
  */
603
- static lift(pos: IPosition): Position;
383
+ isDisposed(): boolean;
604
384
  /**
605
- * Test if `obj` is an `IPosition`.
385
+ * Dispose associated resources
606
386
  */
607
- static isIPosition(obj: any): obj is IPosition;
387
+ dispose(): void;
608
388
  }
609
-
610
- /**
611
- * A range in the editor. This interface is suitable for serialization.
612
- */
613
- interface IRange {
614
- /**
615
- * Line number on which the range starts (starts at 1).
616
- */
617
- readonly startLineNumber: number;
389
+ declare enum EditorActivation {
618
390
  /**
619
- * Column on which the range starts in line `startLineNumber` (starts at 1).
391
+ * Activate the editor after it opened. This will automatically restore
392
+ * the editor if it is minimized.
620
393
  */
621
- readonly startColumn: number;
394
+ ACTIVATE = 1,
622
395
  /**
623
- * Line number on which the range ends.
396
+ * Only restore the editor if it is minimized but do not activate it.
397
+ *
398
+ * Note: will only work in combination with the `preserveFocus: true` option.
399
+ * Otherwise, if focus moves into the editor, it will activate and restore
400
+ * automatically.
624
401
  */
625
- readonly endLineNumber: number;
402
+ RESTORE = 2,
626
403
  /**
627
- * Column on which the range ends in line `endLineNumber`.
404
+ * Preserve the current active editor.
405
+ *
406
+ * Note: will only work in combination with the `preserveFocus: true` option.
407
+ * Otherwise, if focus moves into the editor, it will activate and restore
408
+ * automatically.
628
409
  */
629
- readonly endColumn: number;
410
+ PRESERVE = 3
630
411
  }
631
- /**
632
- * A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)
633
- */
634
- declare class Range {
635
- /**
636
- * Line number on which the range starts (starts at 1).
637
- */
638
- readonly startLineNumber: number;
639
- /**
640
- * Column on which the range starts in line `startLineNumber` (starts at 1).
641
- */
642
- readonly startColumn: number;
643
- /**
644
- * Line number on which the range ends.
645
- */
646
- readonly endLineNumber: number;
647
- /**
648
- * Column on which the range ends in line `endLineNumber`.
649
- */
650
- readonly endColumn: number;
651
- constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number);
652
- /**
653
- * Test if this range is empty.
654
- */
655
- isEmpty(): boolean;
656
- /**
657
- * Test if `range` is empty.
658
- */
659
- static isEmpty(range: IRange): boolean;
660
- /**
661
- * Test if position is in this range. If the position is at the edges, will return true.
662
- */
663
- containsPosition(position: IPosition): boolean;
664
- /**
665
- * Test if `position` is in `range`. If the position is at the edges, will return true.
666
- */
667
- static containsPosition(range: IRange, position: IPosition): boolean;
668
- /**
669
- * Test if `position` is in `range`. If the position is at the edges, will return false.
670
- * @internal
671
- */
672
- static strictContainsPosition(range: IRange, position: IPosition): boolean;
673
- /**
674
- * Test if range is in this range. If the range is equal to this range, will return true.
675
- */
676
- containsRange(range: IRange): boolean;
677
- /**
678
- * Test if `otherRange` is in `range`. If the ranges are equal, will return true.
679
- */
680
- static containsRange(range: IRange, otherRange: IRange): boolean;
681
- /**
682
- * Test if `range` is strictly in this range. `range` must start after and end before this range for the result to be true.
683
- */
684
- strictContainsRange(range: IRange): boolean;
685
- /**
686
- * Test if `otherRange` is strictly in `range` (must start after, and end before). If the ranges are equal, will return false.
687
- */
688
- static strictContainsRange(range: IRange, otherRange: IRange): boolean;
689
- /**
690
- * A reunion of the two ranges.
691
- * The smallest position will be used as the start point, and the largest one as the end point.
692
- */
693
- plusRange(range: IRange): Range;
694
- /**
695
- * A reunion of the two ranges.
696
- * The smallest position will be used as the start point, and the largest one as the end point.
697
- */
698
- static plusRange(a: IRange, b: IRange): Range;
699
- /**
700
- * A intersection of the two ranges.
701
- */
702
- intersectRanges(range: IRange): Range | null;
412
+ declare enum EditorResolution {
703
413
  /**
704
- * A intersection of the two ranges.
414
+ * Displays a picker and allows the user to decide which editor to use.
705
415
  */
706
- static intersectRanges(a: IRange, b: IRange): Range | null;
416
+ PICK = 0,
707
417
  /**
708
- * Test if this range equals other.
418
+ * Only exclusive editors are considered.
709
419
  */
710
- equalsRange(other: IRange | null | undefined): boolean;
420
+ EXCLUSIVE_ONLY = 1
421
+ }
422
+ declare enum EditorOpenSource {
711
423
  /**
712
- * Test if range `a` equals `b`.
424
+ * Default: the editor is opening via a programmatic call
425
+ * to the editor service API.
713
426
  */
714
- static equalsRange(a: IRange | null | undefined, b: IRange | null | undefined): boolean;
427
+ API = 0,
715
428
  /**
716
- * Return the end position (which will be after or equal to the start position)
429
+ * Indicates that a user action triggered the opening, e.g.
430
+ * via mouse or keyboard use.
717
431
  */
718
- getEndPosition(): Position;
432
+ USER = 1
433
+ }
434
+ interface IEditorOptions {
719
435
  /**
720
- * Return the end position (which will be after or equal to the start position)
436
+ * Tells the editor to not receive keyboard focus when the editor is being opened.
437
+ *
438
+ * Will also not activate the group the editor opens in unless the group is already
439
+ * the active one. This behaviour can be overridden via the `activation` option.
721
440
  */
722
- static getEndPosition(range: IRange): Position;
441
+ preserveFocus?: boolean;
723
442
  /**
724
- * Return the start position (which will be before or equal to the end position)
443
+ * This option is only relevant if an editor is opened into a group that is not active
444
+ * already and allows to control if the inactive group should become active, restored
445
+ * or preserved.
446
+ *
447
+ * By default, the editor group will become active unless `preserveFocus` or `inactive`
448
+ * is specified.
725
449
  */
726
- getStartPosition(): Position;
450
+ activation?: EditorActivation;
727
451
  /**
728
- * Return the start position (which will be before or equal to the end position)
452
+ * Tells the editor to reload the editor input in the editor even if it is identical to the one
453
+ * already showing. By default, the editor will not reload the input if it is identical to the
454
+ * one showing.
729
455
  */
730
- static getStartPosition(range: IRange): Position;
456
+ forceReload?: boolean;
731
457
  /**
732
- * Transform to a user presentable string representation.
458
+ * Will reveal the editor if it is already opened and visible in any of the opened editor groups.
459
+ *
460
+ * Note that this option is just a hint that might be ignored if the user wants to open an editor explicitly
461
+ * to the side of another one or into a specific editor group.
733
462
  */
734
- toString(): string;
463
+ revealIfVisible?: boolean;
735
464
  /**
736
- * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
465
+ * Will reveal the editor if it is already opened (even when not visible) in any of the opened editor groups.
466
+ *
467
+ * Note that this option is just a hint that might be ignored if the user wants to open an editor explicitly
468
+ * to the side of another one or into a specific editor group.
737
469
  */
738
- setEndPosition(endLineNumber: number, endColumn: number): Range;
470
+ revealIfOpened?: boolean;
739
471
  /**
740
- * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
472
+ * An editor that is pinned remains in the editor stack even when another editor is being opened.
473
+ * An editor that is not pinned will always get replaced by another editor that is not pinned.
741
474
  */
742
- setStartPosition(startLineNumber: number, startColumn: number): Range;
475
+ pinned?: boolean;
743
476
  /**
744
- * Create a new empty range using this range's start position.
477
+ * An editor that is sticky moves to the beginning of the editors list within the group and will remain
478
+ * there unless explicitly closed. Operations such as "Close All" will not close sticky editors.
745
479
  */
746
- collapseToStart(): Range;
480
+ sticky?: boolean;
747
481
  /**
748
- * Create a new empty range using this range's start position.
482
+ * The index in the document stack where to insert the editor into when opening.
749
483
  */
750
- static collapseToStart(range: IRange): Range;
484
+ index?: number;
751
485
  /**
752
- * Create a new empty range using this range's end position.
486
+ * An active editor that is opened will show its contents directly. Set to true to open an editor
487
+ * in the background without loading its contents.
488
+ *
489
+ * Will also not activate the group the editor opens in unless the group is already
490
+ * the active one. This behaviour can be overridden via the `activation` option.
753
491
  */
754
- collapseToEnd(): Range;
492
+ inactive?: boolean;
755
493
  /**
756
- * Create a new empty range using this range's end position.
494
+ * Will not show an error in case opening the editor fails and thus allows to show a custom error
495
+ * message as needed. By default, an error will be presented as notification if opening was not possible.
757
496
  */
758
- static collapseToEnd(range: IRange): Range;
759
497
  /**
760
- * Moves the range by the given amount of lines.
498
+ * In case of an error opening the editor, will not present this error to the user (e.g. by showing
499
+ * a generic placeholder in the editor area). So it is up to the caller to provide error information
500
+ * in that case.
501
+ *
502
+ * By default, an error when opening an editor will result in a placeholder editor that shows the error.
503
+ * In certain cases a modal dialog may be presented to ask the user for further action.
761
504
  */
762
- delta(lineCount: number): Range;
763
- static fromPositions(start: IPosition, end?: IPosition): Range;
505
+ ignoreError?: boolean;
764
506
  /**
765
- * Create a `Range` from an `IRange`.
507
+ * Allows to override the editor that should be used to display the input:
508
+ * - `undefined`: let the editor decide for itself
509
+ * - `string`: specific override by id
510
+ * - `EditorResolution`: specific override handling
766
511
  */
767
- static lift(range: undefined | null): null;
768
- static lift(range: IRange): Range;
769
- static lift(range: IRange | undefined | null): Range | null;
512
+ override?: string | EditorResolution;
770
513
  /**
771
- * Test if `obj` is an `IRange`.
514
+ * A optional hint to signal in which context the editor opens.
515
+ *
516
+ * If configured to be `EditorOpenSource.USER`, this hint can be
517
+ * used in various places to control the experience. For example,
518
+ * if the editor to open fails with an error, a notification could
519
+ * inform about this in a modal dialog. If the editor opened through
520
+ * some background task, the notification would show in the background,
521
+ * not as a modal dialog.
772
522
  */
773
- static isIRange(obj: any): obj is IRange;
523
+ source?: EditorOpenSource;
774
524
  /**
775
- * Test if the two ranges are touching in any way.
525
+ * An optional property to signal that certain view state should be
526
+ * applied when opening the editor.
776
527
  */
777
- static areIntersectingOrTouching(a: IRange, b: IRange): boolean;
528
+ viewState?: object;
529
+ }
530
+
531
+ type IEditorOverrideServices = monaco.editor.IEditorOverrideServices
532
+
533
+ interface ITextEditorModel extends IEditorModel {
778
534
  /**
779
- * Test if the two ranges are intersecting. If the ranges are touching it returns true.
535
+ * Provides access to the underlying `ITextModel`.
780
536
  */
781
- static areIntersecting(a: IRange, b: IRange): boolean;
537
+ readonly textEditorModel: ITextModel | null;
782
538
  /**
783
- * A function that compares ranges, useful for sorting ranges
784
- * It will first compare ranges on the startPosition and then on the endPosition
539
+ * Creates a snapshot of the model's contents.
785
540
  */
786
- static compareRangesUsingStarts(a: IRange | null | undefined, b: IRange | null | undefined): number;
541
+ createSnapshot(this: IResolvedTextEditorModel): ITextSnapshot;
542
+ createSnapshot(this: ITextEditorModel): ITextSnapshot | null;
787
543
  /**
788
- * A function that compares ranges, useful for sorting ranges
789
- * It will first compare ranges on the endPosition and then on the startPosition
544
+ * Signals if this model is readonly or not.
790
545
  */
791
- static compareRangesUsingEnds(a: IRange, b: IRange): number;
546
+ isReadonly(): boolean;
792
547
  /**
793
- * Test if the range spans multiple lines.
548
+ * The language id of the text model if known.
794
549
  */
795
- static spansMultipleLines(range: IRange): boolean;
796
- toJSON(): IRange;
550
+ getLanguageId(): string | undefined;
797
551
  }
798
-
799
- /**
800
- * A single edit operation, that acts as a simple replace.
801
- * i.e. Replace text at `range` with `text` in model.
802
- */
803
- interface ISingleEditOperation {
804
- /**
805
- * The range to replace. This can be empty to emulate a simple insert.
806
- */
807
- range: IRange;
808
- /**
809
- * The text to replace with. This can be null to emulate a simple delete.
810
- */
811
- text: string | null;
552
+ interface IResolvedTextEditorModel extends ITextEditorModel {
812
553
  /**
813
- * This indicates that this operation has "insert" semantics.
814
- * i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
554
+ * Same as ITextEditorModel#textEditorModel, but never null.
815
555
  */
816
- forceMoveMarkers?: boolean;
817
- }
818
-
819
- declare class TextChange {
820
- readonly oldPosition: number;
821
- readonly oldText: string;
822
- readonly newPosition: number;
823
- readonly newText: string;
824
- get oldLength(): number;
825
- get oldEnd(): number;
826
- get newLength(): number;
827
- get newEnd(): number;
828
- constructor(oldPosition: number, oldText: string, newPosition: number, newText: string);
829
- toString(): string;
830
- private static _writeStringSize;
831
- private static _writeString;
832
- private static _readString;
833
- writeSize(): number;
834
- write(b: Uint8Array, offset: number): number;
835
- static read(b: Uint8Array, offset: number, dest: TextChange[]): number;
836
- }
837
-
838
- /**
839
- * A fast character classifier that uses a compact array for ASCII values.
840
- */
841
- declare class CharacterClassifier<T extends number> {
842
- /**
843
- * Maintain a compact (fully initialized ASCII map for quickly classifying ASCII characters - used more often in code).
844
- */
845
- protected readonly _asciiMap: Uint8Array;
846
- /**
847
- * The entire map (sparse array).
848
- */
849
- protected readonly _map: Map<number, number>;
850
- protected readonly _defaultValue: number;
851
- constructor(_defaultValue: T);
852
- private static _createAsciiMap;
853
- set(charCode: number, _value: T): void;
854
- get(charCode: number): T;
855
- clear(): void;
856
- }
857
-
858
- declare const enum WordCharacterClass {
859
- Regular = 0,
860
- Whitespace = 1,
861
- WordSeparator = 2
862
- }
863
- declare class WordCharacterClassifier extends CharacterClassifier<WordCharacterClass> {
864
- constructor(wordSeparators: string);
865
- }
866
-
867
- interface IModelContentChange {
868
- /**
869
- * The range that got replaced.
870
- */
871
- readonly range: IRange;
872
- /**
873
- * The offset of the range that got replaced.
874
- */
875
- readonly rangeOffset: number;
876
- /**
877
- * The length of the range that got replaced.
878
- */
879
- readonly rangeLength: number;
880
- /**
881
- * The new text for the range.
882
- */
883
- readonly text: string;
884
- }
885
-
886
- /**
887
- * End of line character preference.
888
- */
889
- declare const enum EndOfLinePreference {
890
- /**
891
- * Use the end of line character identified in the text buffer.
892
- */
893
- TextDefined = 0,
894
- /**
895
- * Use line feed (\n) as the end of line character.
896
- */
897
- LF = 1,
898
- /**
899
- * Use carriage return and line feed (\r\n) as the end of line character.
900
- */
901
- CRLF = 2
902
- }
903
- /**
904
- * The default end of line to use when instantiating models.
905
- */
906
- declare const enum DefaultEndOfLine {
907
- /**
908
- * Use line feed (\n) as the end of line character.
909
- */
910
- LF = 1,
911
- /**
912
- * Use carriage return and line feed (\r\n) as the end of line character.
913
- */
914
- CRLF = 2
915
- }
916
- /**
917
- * An identifier for a single edit operation.
918
- * @internal
919
- */
920
- interface ISingleEditOperationIdentifier {
921
- /**
922
- * Identifier major
923
- */
924
- major: number;
925
- /**
926
- * Identifier minor
927
- */
928
- minor: number;
929
- }
930
- /**
931
- * A single edit operation, that has an identifier.
932
- */
933
- interface IIdentifiedSingleEditOperation extends ISingleEditOperation {
934
- /**
935
- * An identifier associated with this single edit operation.
936
- * @internal
937
- */
938
- identifier?: ISingleEditOperationIdentifier | null;
939
- /**
940
- * This indicates that this operation is inserting automatic whitespace
941
- * that can be removed on next model edit operation if `config.trimAutoWhitespace` is true.
942
- * @internal
943
- */
944
- isAutoWhitespaceEdit?: boolean;
945
- /**
946
- * This indicates that this operation is in a set of operations that are tracked and should not be "simplified".
947
- * @internal
948
- */
949
- _isTracked?: boolean;
950
- }
951
- interface IValidEditOperation {
952
- /**
953
- * An identifier associated with this single edit operation.
954
- * @internal
955
- */
956
- identifier: ISingleEditOperationIdentifier | null;
957
- /**
958
- * The range to replace. This can be empty to emulate a simple insert.
959
- */
960
- range: Range;
961
- /**
962
- * The text to replace with. This can be empty to emulate a simple delete.
963
- */
964
- text: string;
965
- /**
966
- * @internal
967
- */
968
- textChange: TextChange;
969
- }
970
- declare class FindMatch {
971
- _findMatchBrand: void;
972
- readonly range: Range;
973
- readonly matches: string[] | null;
974
- /**
975
- * @internal
976
- */
977
- constructor(range: Range, matches: string[] | null);
978
- }
979
- /**
980
- * Text snapshot that works like an iterator.
981
- * Will try to return chunks of roughly ~64KB size.
982
- * Will return null when finished.
983
- */
984
- interface ITextSnapshot {
985
- read(): string | null;
986
- }
987
- /**
988
- * A model.
989
- */
990
- type ITextModel = monaco.editor.ITextModel
991
- /**
992
- * @internal
993
- */
994
- interface ITextBufferFactory {
995
- create(defaultEOL: DefaultEndOfLine): {
996
- textBuffer: ITextBuffer;
997
- disposable: IDisposable;
998
- };
999
- getFirstLineText(lengthLimit: number): string;
1000
- }
1001
- /**
1002
- * @internal
1003
- */
1004
- declare class ValidAnnotatedEditOperation implements IIdentifiedSingleEditOperation {
1005
- readonly identifier: ISingleEditOperationIdentifier | null;
1006
- readonly range: Range;
1007
- readonly text: string | null;
1008
- readonly forceMoveMarkers: boolean;
1009
- readonly isAutoWhitespaceEdit: boolean;
1010
- readonly _isTracked: boolean;
1011
- constructor(identifier: ISingleEditOperationIdentifier | null, range: Range, text: string | null, forceMoveMarkers: boolean, isAutoWhitespaceEdit: boolean, _isTracked: boolean);
1012
- }
1013
- /**
1014
- * @internal
1015
- *
1016
- * `lineNumber` is 1 based.
1017
- */
1018
- interface IReadonlyTextBuffer {
1019
- onDidChangeContent: Event<void>;
1020
- equals(other: ITextBuffer): boolean;
1021
- mightContainRTL(): boolean;
1022
- mightContainUnusualLineTerminators(): boolean;
1023
- resetMightContainUnusualLineTerminators(): void;
1024
- mightContainNonBasicASCII(): boolean;
1025
- getBOM(): string;
1026
- getEOL(): string;
1027
- getOffsetAt(lineNumber: number, column: number): number;
1028
- getPositionAt(offset: number): Position;
1029
- getRangeAt(offset: number, length: number): Range;
1030
- getValueInRange(range: Range, eol: EndOfLinePreference): string;
1031
- createSnapshot(preserveBOM: boolean): ITextSnapshot;
1032
- getValueLengthInRange(range: Range, eol: EndOfLinePreference): number;
1033
- getCharacterCountInRange(range: Range, eol: EndOfLinePreference): number;
1034
- getLength(): number;
1035
- getLineCount(): number;
1036
- getLinesContent(): string[];
1037
- getLineContent(lineNumber: number): string;
1038
- getLineCharCode(lineNumber: number, index: number): number;
1039
- getCharCode(offset: number): number;
1040
- getLineLength(lineNumber: number): number;
1041
- getLineFirstNonWhitespaceColumn(lineNumber: number): number;
1042
- getLineLastNonWhitespaceColumn(lineNumber: number): number;
1043
- findMatchesLineByLine(searchRange: Range, searchData: SearchData, captureMatches: boolean, limitResultCount: number): FindMatch[];
1044
- }
1045
- /**
1046
- * @internal
1047
- */
1048
- declare class SearchData {
1049
- /**
1050
- * The regex to search for. Always defined.
1051
- */
1052
- readonly regex: RegExp;
1053
- /**
1054
- * The word separator classifier.
1055
- */
1056
- readonly wordSeparators: WordCharacterClassifier | null;
1057
- /**
1058
- * The simple string to search for (if possible).
1059
- */
1060
- readonly simpleSearch: string | null;
1061
- constructor(regex: RegExp, wordSeparators: WordCharacterClassifier | null, simpleSearch: string | null);
1062
- }
1063
- /**
1064
- * @internal
1065
- */
1066
- interface ITextBuffer extends IReadonlyTextBuffer {
1067
- setEOL(newEOL: '\r\n' | '\n'): void;
1068
- applyEdits(rawOperations: ValidAnnotatedEditOperation[], recordTrimAutoWhitespace: boolean, computeUndoEdits: boolean): ApplyEditsResult;
1069
- }
1070
- /**
1071
- * @internal
1072
- */
1073
- declare class ApplyEditsResult {
1074
- readonly reverseEdits: IValidEditOperation[] | null;
1075
- readonly changes: IInternalModelContentChange[];
1076
- readonly trimAutoWhitespaceLineNumbers: number[] | null;
1077
- constructor(reverseEdits: IValidEditOperation[] | null, changes: IInternalModelContentChange[], trimAutoWhitespaceLineNumbers: number[] | null);
1078
- }
1079
- /**
1080
- * @internal
1081
- */
1082
- interface IInternalModelContentChange extends IModelContentChange {
1083
- range: Range;
1084
- forceMoveMarkers: boolean;
1085
- }
1086
-
1087
- /**
1088
- * A rich code editor.
1089
- */
1090
- type ICodeEditor = monaco.editor.ICodeEditor
1091
-
1092
- interface IEditorModel {
1093
- /**
1094
- * Emitted when the model is about to be disposed.
1095
- */
1096
- readonly onWillDispose: Event<void>;
1097
- /**
1098
- * Resolves the model.
1099
- */
1100
- resolve(): Promise<void>;
1101
- /**
1102
- * Find out if the editor model was resolved or not.
1103
- */
1104
- isResolved(): boolean;
1105
- /**
1106
- * Find out if this model has been disposed.
1107
- */
1108
- isDisposed(): boolean;
1109
- /**
1110
- * Dispose associated resources
1111
- */
1112
- dispose(): void;
1113
- }
1114
- declare enum EditorActivation {
1115
- /**
1116
- * Activate the editor after it opened. This will automatically restore
1117
- * the editor if it is minimized.
1118
- */
1119
- ACTIVATE = 1,
1120
- /**
1121
- * Only restore the editor if it is minimized but do not activate it.
1122
- *
1123
- * Note: will only work in combination with the `preserveFocus: true` option.
1124
- * Otherwise, if focus moves into the editor, it will activate and restore
1125
- * automatically.
1126
- */
1127
- RESTORE = 2,
1128
- /**
1129
- * Preserve the current active editor.
1130
- *
1131
- * Note: will only work in combination with the `preserveFocus: true` option.
1132
- * Otherwise, if focus moves into the editor, it will activate and restore
1133
- * automatically.
1134
- */
1135
- PRESERVE = 3
1136
- }
1137
- declare enum EditorResolution {
1138
- /**
1139
- * Displays a picker and allows the user to decide which editor to use.
1140
- */
1141
- PICK = 0,
1142
- /**
1143
- * Only exclusive editors are considered.
1144
- */
1145
- EXCLUSIVE_ONLY = 1
1146
- }
1147
- declare enum EditorOpenSource {
1148
- /**
1149
- * Default: the editor is opening via a programmatic call
1150
- * to the editor service API.
1151
- */
1152
- API = 0,
1153
- /**
1154
- * Indicates that a user action triggered the opening, e.g.
1155
- * via mouse or keyboard use.
1156
- */
1157
- USER = 1
1158
- }
1159
- interface IEditorOptions {
1160
- /**
1161
- * Tells the editor to not receive keyboard focus when the editor is being opened.
1162
- *
1163
- * Will also not activate the group the editor opens in unless the group is already
1164
- * the active one. This behaviour can be overridden via the `activation` option.
1165
- */
1166
- preserveFocus?: boolean;
1167
- /**
1168
- * This option is only relevant if an editor is opened into a group that is not active
1169
- * already and allows to control if the inactive group should become active, restored
1170
- * or preserved.
1171
- *
1172
- * By default, the editor group will become active unless `preserveFocus` or `inactive`
1173
- * is specified.
1174
- */
1175
- activation?: EditorActivation;
1176
- /**
1177
- * Tells the editor to reload the editor input in the editor even if it is identical to the one
1178
- * already showing. By default, the editor will not reload the input if it is identical to the
1179
- * one showing.
1180
- */
1181
- forceReload?: boolean;
1182
- /**
1183
- * Will reveal the editor if it is already opened and visible in any of the opened editor groups.
1184
- *
1185
- * Note that this option is just a hint that might be ignored if the user wants to open an editor explicitly
1186
- * to the side of another one or into a specific editor group.
1187
- */
1188
- revealIfVisible?: boolean;
1189
- /**
1190
- * Will reveal the editor if it is already opened (even when not visible) in any of the opened editor groups.
1191
- *
1192
- * Note that this option is just a hint that might be ignored if the user wants to open an editor explicitly
1193
- * to the side of another one or into a specific editor group.
1194
- */
1195
- revealIfOpened?: boolean;
1196
- /**
1197
- * An editor that is pinned remains in the editor stack even when another editor is being opened.
1198
- * An editor that is not pinned will always get replaced by another editor that is not pinned.
1199
- */
1200
- pinned?: boolean;
1201
- /**
1202
- * An editor that is sticky moves to the beginning of the editors list within the group and will remain
1203
- * there unless explicitly closed. Operations such as "Close All" will not close sticky editors.
1204
- */
1205
- sticky?: boolean;
1206
- /**
1207
- * The index in the document stack where to insert the editor into when opening.
1208
- */
1209
- index?: number;
1210
- /**
1211
- * An active editor that is opened will show its contents directly. Set to true to open an editor
1212
- * in the background without loading its contents.
1213
- *
1214
- * Will also not activate the group the editor opens in unless the group is already
1215
- * the active one. This behaviour can be overridden via the `activation` option.
1216
- */
1217
- inactive?: boolean;
1218
- /**
1219
- * Will not show an error in case opening the editor fails and thus allows to show a custom error
1220
- * message as needed. By default, an error will be presented as notification if opening was not possible.
1221
- */
1222
- /**
1223
- * In case of an error opening the editor, will not present this error to the user (e.g. by showing
1224
- * a generic placeholder in the editor area). So it is up to the caller to provide error information
1225
- * in that case.
1226
- *
1227
- * By default, an error when opening an editor will result in a placeholder editor that shows the error.
1228
- * In certain cases a modal dialog may be presented to ask the user for further action.
1229
- */
1230
- ignoreError?: boolean;
1231
- /**
1232
- * Allows to override the editor that should be used to display the input:
1233
- * - `undefined`: let the editor decide for itself
1234
- * - `string`: specific override by id
1235
- * - `EditorResolution`: specific override handling
1236
- */
1237
- override?: string | EditorResolution;
1238
- /**
1239
- * A optional hint to signal in which context the editor opens.
1240
- *
1241
- * If configured to be `EditorOpenSource.USER`, this hint can be
1242
- * used in various places to control the experience. For example,
1243
- * if the editor to open fails with an error, a notification could
1244
- * inform about this in a modal dialog. If the editor opened through
1245
- * some background task, the notification would show in the background,
1246
- * not as a modal dialog.
1247
- */
1248
- source?: EditorOpenSource;
1249
- /**
1250
- * An optional property to signal that certain view state should be
1251
- * applied when opening the editor.
1252
- */
1253
- viewState?: object;
1254
- }
1255
-
1256
- type IEditorOverrideServices = monaco.editor.IEditorOverrideServices
1257
-
1258
- interface ITextEditorModel extends IEditorModel {
1259
- /**
1260
- * Provides access to the underlying `ITextModel`.
1261
- */
1262
- readonly textEditorModel: ITextModel | null;
1263
- /**
1264
- * Creates a snapshot of the model's contents.
1265
- */
1266
- createSnapshot(this: IResolvedTextEditorModel): ITextSnapshot;
1267
- createSnapshot(this: ITextEditorModel): ITextSnapshot | null;
1268
- /**
1269
- * Signals if this model is readonly or not.
1270
- */
1271
- isReadonly(): boolean;
1272
- /**
1273
- * The language id of the text model if known.
1274
- */
1275
- getLanguageId(): string | undefined;
1276
- }
1277
- interface IResolvedTextEditorModel extends ITextEditorModel {
1278
- /**
1279
- * Same as ITextEditorModel#textEditorModel, but never null.
1280
- */
1281
- readonly textEditorModel: ITextModel;
1282
- }
1283
-
1284
- interface ReadableStreamEvents<T> {
1285
- /**
1286
- * The 'data' event is emitted whenever the stream is
1287
- * relinquishing ownership of a chunk of data to a consumer.
1288
- *
1289
- * NOTE: PLEASE UNDERSTAND THAT ADDING A DATA LISTENER CAN
1290
- * TURN THE STREAM INTO FLOWING MODE. IT IS THEREFOR THE
1291
- * LAST LISTENER THAT SHOULD BE ADDED AND NOT THE FIRST
1292
- *
1293
- * Use `listenStream` as a helper method to listen to
1294
- * stream events in the right order.
1295
- */
1296
- on(event: 'data', callback: (data: T) => void): void;
1297
- /**
1298
- * Emitted when any error occurs.
1299
- */
1300
- on(event: 'error', callback: (err: Error) => void): void;
1301
- /**
1302
- * The 'end' event is emitted when there is no more data
1303
- * to be consumed from the stream. The 'end' event will
1304
- * not be emitted unless the data is completely consumed.
1305
- */
1306
- on(event: 'end', callback: () => void): void;
1307
- }
1308
- /**
1309
- * A interface that emulates the API shape of a node.js readable
1310
- * stream for use in native and web environments.
1311
- */
1312
- interface ReadableStream<T> extends ReadableStreamEvents<T> {
1313
- /**
1314
- * Stops emitting any events until resume() is called.
1315
- */
1316
- pause(): void;
1317
- /**
1318
- * Starts emitting events again after pause() was called.
1319
- */
1320
- resume(): void;
1321
- /**
1322
- * Destroys the stream and stops emitting any event.
1323
- */
1324
- destroy(): void;
1325
- /**
1326
- * Allows to remove a listener that was previously added.
1327
- */
1328
- removeListener(event: string, callback: Function): void;
1329
- }
1330
- /**
1331
- * A interface that emulates the API shape of a node.js readable
1332
- * for use in native and web environments.
1333
- */
1334
- interface Readable<T> {
1335
- /**
1336
- * Read data from the underlying source. Will return
1337
- * null to indicate that no more data can be read.
1338
- */
1339
- read(): T | null;
1340
- }
1341
-
1342
- declare class VSBuffer {
1343
- /**
1344
- * When running in a nodejs context, the backing store for the returned `VSBuffer` instance
1345
- * might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
1346
- */
1347
- static alloc(byteLength: number): VSBuffer;
1348
- /**
1349
- * When running in a nodejs context, if `actual` is not a nodejs Buffer, the backing store for
1350
- * the returned `VSBuffer` instance might use a nodejs Buffer allocated from node's Buffer pool,
1351
- * which is not transferrable.
1352
- */
1353
- static wrap(actual: Uint8Array): VSBuffer;
1354
- /**
1355
- * When running in a nodejs context, the backing store for the returned `VSBuffer` instance
1356
- * might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
1357
- */
1358
- static fromString(source: string, options?: {
1359
- dontUseNodeBuffer?: boolean;
1360
- }): VSBuffer;
1361
- /**
1362
- * When running in a nodejs context, the backing store for the returned `VSBuffer` instance
1363
- * might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
1364
- */
1365
- static fromByteArray(source: number[]): VSBuffer;
1366
- /**
1367
- * When running in a nodejs context, the backing store for the returned `VSBuffer` instance
1368
- * might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
1369
- */
1370
- static concat(buffers: VSBuffer[], totalLength?: number): VSBuffer;
1371
- readonly buffer: Uint8Array;
1372
- readonly byteLength: number;
1373
- private constructor();
1374
- /**
1375
- * When running in a nodejs context, the backing store for the returned `VSBuffer` instance
1376
- * might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
1377
- */
1378
- clone(): VSBuffer;
1379
- toString(): string;
1380
- slice(start?: number, end?: number): VSBuffer;
1381
- set(array: VSBuffer, offset?: number): void;
1382
- set(array: Uint8Array, offset?: number): void;
1383
- set(array: ArrayBuffer, offset?: number): void;
1384
- set(array: ArrayBufferView, offset?: number): void;
1385
- set(array: VSBuffer | Uint8Array | ArrayBuffer | ArrayBufferView, offset?: number): void;
1386
- readUInt32BE(offset: number): number;
1387
- writeUInt32BE(value: number, offset: number): void;
1388
- readUInt32LE(offset: number): number;
1389
- writeUInt32LE(value: number, offset: number): void;
1390
- readUInt8(offset: number): number;
1391
- writeUInt8(value: number, offset: number): void;
1392
- }
1393
- interface VSBufferReadable extends Readable<VSBuffer> {
1394
- }
1395
- interface VSBufferReadableStream extends ReadableStream<VSBuffer> {
1396
- }
1397
-
1398
- interface IFileReadLimits {
1399
- /**
1400
- * If the file exceeds the given size, an error of kind
1401
- * `FILE_TOO_LARGE` will be thrown.
1402
- */
1403
- size?: number;
1404
- /**
1405
- * If the file exceeds the given size, an error of kind
1406
- * `FILE_EXCEEDS_MEMORY_LIMIT` will be thrown.
1407
- */
1408
- memory?: number;
1409
- }
1410
- interface IBaseFileStat {
1411
- /**
1412
- * The unified resource identifier of this file or folder.
1413
- */
1414
- readonly resource: URI;
1415
- /**
1416
- * The name which is the last segment
1417
- * of the {{path}}.
1418
- */
1419
- readonly name: string;
1420
- /**
1421
- * The size of the file.
1422
- *
1423
- * The value may or may not be resolved as
1424
- * it is optional.
1425
- */
1426
- readonly size?: number;
1427
- /**
1428
- * The last modification date represented as millis from unix epoch.
1429
- *
1430
- * The value may or may not be resolved as
1431
- * it is optional.
1432
- */
1433
- readonly mtime?: number;
1434
- /**
1435
- * The creation date represented as millis from unix epoch.
1436
- *
1437
- * The value may or may not be resolved as
1438
- * it is optional.
1439
- */
1440
- readonly ctime?: number;
1441
- /**
1442
- * A unique identifier that represents the
1443
- * current state of the file or directory.
1444
- *
1445
- * The value may or may not be resolved as
1446
- * it is optional.
1447
- */
1448
- readonly etag?: string;
1449
- /**
1450
- * The file is read-only.
1451
- */
1452
- readonly readonly?: boolean;
1453
- }
1454
- interface IBaseFileStatWithMetadata extends Required<IBaseFileStat> {
1455
- }
1456
- /**
1457
- * A file resource with meta information and resolved children if any.
1458
- */
1459
- interface IFileStat extends IBaseFileStat {
1460
- /**
1461
- * The resource is a file.
1462
- */
1463
- readonly isFile: boolean;
1464
- /**
1465
- * The resource is a directory.
1466
- */
1467
- readonly isDirectory: boolean;
1468
- /**
1469
- * The resource is a symbolic link. Note: even when the
1470
- * file is a symbolic link, you can test for `FileType.File`
1471
- * and `FileType.Directory` to know the type of the target
1472
- * the link points to.
1473
- */
1474
- readonly isSymbolicLink: boolean;
1475
- /**
1476
- * The children of the file stat or undefined if none.
1477
- */
1478
- children: IFileStat[] | undefined;
1479
- }
1480
- interface IFileStatWithMetadata extends IFileStat, IBaseFileStatWithMetadata {
1481
- readonly mtime: number;
1482
- readonly ctime: number;
1483
- readonly etag: string;
1484
- readonly size: number;
1485
- readonly readonly: boolean;
1486
- readonly children: IFileStatWithMetadata[] | undefined;
1487
- }
1488
-
1489
- declare const enum SaveReason {
1490
- /**
1491
- * Explicit user gesture.
1492
- */
1493
- EXPLICIT = 1,
1494
- /**
1495
- * Auto save after a timeout.
1496
- */
1497
- AUTO = 2,
1498
- /**
1499
- * Auto save after editor focus change.
1500
- */
1501
- FOCUS_CHANGE = 3,
1502
- /**
1503
- * Auto save after window change.
1504
- */
1505
- WINDOW_CHANGE = 4
1506
- }
1507
- type SaveSource = string;
1508
- interface ISaveOptions {
1509
- /**
1510
- * An indicator how the save operation was triggered.
1511
- */
1512
- reason?: SaveReason;
1513
- /**
1514
- * An indicator about the source of the save operation.
1515
- *
1516
- * Must use `SaveSourceRegistry.registerSource()` to obtain.
1517
- */
1518
- readonly source?: SaveSource;
1519
- /**
1520
- * Forces to save the contents of the working copy
1521
- * again even if the working copy is not dirty.
1522
- */
1523
- readonly force?: boolean;
1524
- /**
1525
- * Instructs the save operation to skip any save participants.
1526
- */
1527
- readonly skipSaveParticipants?: boolean;
1528
- /**
1529
- * A hint as to which file systems should be available for saving.
1530
- */
1531
- readonly availableFileSystems?: string[];
1532
- }
1533
- interface IRevertOptions {
1534
- /**
1535
- * Forces to load the contents of the working copy
1536
- * again even if the working copy is not dirty.
1537
- */
1538
- readonly force?: boolean;
1539
- /**
1540
- * A soft revert will clear dirty state of a working copy
1541
- * but will not attempt to load it from its persisted state.
1542
- *
1543
- * This option may be used in scenarios where an editor is
1544
- * closed and where we do not require to load the contents.
1545
- */
1546
- readonly soft?: boolean;
1547
- }
1548
-
1549
- declare const enum WorkingCopyCapabilities {
1550
- /**
1551
- * Signals no specific capability for the working copy.
1552
- */
1553
- None = 0,
1554
- /**
1555
- * Signals that the working copy requires
1556
- * additional input when saving, e.g. an
1557
- * associated path to save to.
1558
- */
1559
- Untitled = 2
1560
- }
1561
- /**
1562
- * Data to be associated with working copy backups. Use
1563
- * `IWorkingCopyBackupService.resolve(workingCopy)` to
1564
- * retrieve the backup when loading the working copy.
1565
- */
1566
- interface IWorkingCopyBackup {
1567
- /**
1568
- * Any serializable metadata to be associated with the backup.
1569
- */
1570
- meta?: IWorkingCopyBackupMeta;
1571
- /**
1572
- * The actual snapshot of the contents of the working copy at
1573
- * the time the backup was made.
1574
- */
1575
- content?: VSBufferReadable | VSBufferReadableStream;
1576
- }
1577
- /**
1578
- * Working copy backup metadata that can be associated
1579
- * with the backup.
1580
- *
1581
- * Some properties may be reserved as outlined here and
1582
- * cannot be used.
1583
- */
1584
- interface IWorkingCopyBackupMeta {
1585
- /**
1586
- * Any property needs to be serializable through JSON.
1587
- */
1588
- [key: string]: unknown;
1589
- /**
1590
- * `typeId` is a reserved property that cannot be used
1591
- * as backup metadata.
1592
- */
1593
- typeId?: never;
1594
- }
1595
- /**
1596
- * Every working copy has in common that it is identified by
1597
- * a resource `URI` and a `typeId`. There can only be one
1598
- * working copy registered with the same `URI` and `typeId`.
1599
- */
1600
- interface IWorkingCopyIdentifier {
1601
- /**
1602
- * The type identifier of the working copy for grouping
1603
- * working copies of the same domain together.
1604
- *
1605
- * There can only be one working copy for a given resource
1606
- * and type identifier.
1607
- */
1608
- readonly typeId: string;
1609
- /**
1610
- * The resource of the working copy must be unique for
1611
- * working copies of the same `typeId`.
1612
- */
1613
- readonly resource: URI;
1614
- }
1615
- interface IWorkingCopySaveEvent {
1616
- /**
1617
- * The reason why the working copy was saved.
1618
- */
1619
- readonly reason?: SaveReason;
1620
- /**
1621
- * The source of the working copy save request.
1622
- */
1623
- readonly source?: SaveSource;
1624
- }
1625
- /**
1626
- * A working copy is an abstract concept to unify handling of
1627
- * data that can be worked on (e.g. edited) in an editor.
1628
- *
1629
- *
1630
- * A working copy resource may be the backing store of the data
1631
- * (e.g. a file on disk), but that is not a requirement. If
1632
- * your working copy is file based, consider to use the
1633
- * `IFileWorkingCopy` instead that simplifies a lot of things
1634
- * when working with file based working copies.
1635
- */
1636
- interface IWorkingCopy extends IWorkingCopyIdentifier {
1637
- /**
1638
- * Human readable name of the working copy.
1639
- */
1640
- readonly name: string;
1641
- /**
1642
- * The capabilities of the working copy.
1643
- */
1644
- readonly capabilities: WorkingCopyCapabilities;
1645
- /**
1646
- * Used by the workbench to signal if the working copy
1647
- * is dirty or not. Typically a working copy is dirty
1648
- * once changed until saved or reverted.
1649
- */
1650
- readonly onDidChangeDirty: Event<void>;
1651
- /**
1652
- * Used by the workbench e.g. to trigger auto-save
1653
- * (unless this working copy is untitled) and backups.
1654
- */
1655
- readonly onDidChangeContent: Event<void>;
1656
- /**
1657
- * Used by the workbench e.g. to track local history
1658
- * (unless this working copy is untitled).
1659
- */
1660
- readonly onDidSave: Event<IWorkingCopySaveEvent>;
1661
- isDirty(): boolean;
1662
- /**
1663
- * The workbench may call this method often after it receives
1664
- * the `onDidChangeContent` event for the working copy. The motivation
1665
- * is to allow to quit VSCode with dirty working copies present.
1666
- *
1667
- * Providers of working copies should use `IWorkingCopyBackupService.resolve(workingCopy)`
1668
- * to retrieve the backup metadata associated when loading the working copy.
1669
- *
1670
- * @param token support for cancellation
1671
- */
1672
- backup(token: CancellationToken): Promise<IWorkingCopyBackup>;
1673
- /**
1674
- * Asks the working copy to save. If the working copy was dirty, it is
1675
- * expected to be non-dirty after this operation has finished.
1676
- *
1677
- * @returns `true` if the operation was successful and `false` otherwise.
1678
- */
1679
- save(options?: ISaveOptions): Promise<boolean>;
1680
- /**
1681
- * Asks the working copy to revert. If the working copy was dirty, it is
1682
- * expected to be non-dirty after this operation has finished.
1683
- */
1684
- revert(options?: IRevertOptions): Promise<void>;
1685
- }
1686
-
1687
- /**
1688
- * States the text file editor model can be in.
1689
- */
1690
- declare const enum TextFileEditorModelState {
1691
- /**
1692
- * A model is saved.
1693
- */
1694
- SAVED = 0,
1695
- /**
1696
- * A model is dirty.
1697
- */
1698
- DIRTY = 1,
1699
- /**
1700
- * A model is currently being saved but this operation has not completed yet.
1701
- */
1702
- PENDING_SAVE = 2,
1703
- /**
1704
- * A model is in conflict mode when changes cannot be saved because the
1705
- * underlying file has changed. Models in conflict mode are always dirty.
1706
- */
1707
- CONFLICT = 3,
1708
- /**
1709
- * A model is in orphan state when the underlying file has been deleted.
1710
- */
1711
- ORPHAN = 4,
1712
- /**
1713
- * Any error that happens during a save that is not causing the CONFLICT state.
1714
- * Models in error mode are always dirty.
1715
- */
1716
- ERROR = 5
1717
- }
1718
- declare const enum TextFileResolveReason {
1719
- EDITOR = 1,
1720
- REFERENCE = 2,
1721
- OTHER = 3
1722
- }
1723
- interface ITextFileSaveOptions extends ISaveOptions {
1724
- /**
1725
- * Save the file with an attempt to unlock it.
1726
- */
1727
- readonly writeUnlock?: boolean;
1728
- /**
1729
- * Save the file with elevated privileges.
1730
- *
1731
- * Note: This may not be supported in all environments.
1732
- */
1733
- readonly writeElevated?: boolean;
1734
- /**
1735
- * Allows to write to a file even if it has been modified on disk.
1736
- */
1737
- readonly ignoreModifiedSince?: boolean;
1738
- /**
1739
- * If set, will bubble up the error to the caller instead of handling it.
1740
- */
1741
- readonly ignoreErrorHandler?: boolean;
1742
- }
1743
- interface ITextFileResolveOptions {
1744
- /**
1745
- * The contents to use for the model if known. If not
1746
- * provided, the contents will be retrieved from the
1747
- * underlying resource or backup if present.
1748
- */
1749
- readonly contents?: ITextBufferFactory;
1750
- /**
1751
- * Go to file bypassing any cache of the model if any.
1752
- */
1753
- readonly forceReadFromFile?: boolean;
1754
- /**
1755
- * Allow to resolve a model even if we think it is a binary file.
1756
- */
1757
- readonly allowBinary?: boolean;
1758
- /**
1759
- * Context why the model is being resolved.
1760
- */
1761
- readonly reason?: TextFileResolveReason;
1762
- /**
1763
- * If provided, the size of the file will be checked against the limits
1764
- * and an error will be thrown if any limit is exceeded.
1765
- */
1766
- readonly limits?: IFileReadLimits;
1767
- }
1768
- declare const enum EncodingMode {
1769
- /**
1770
- * Instructs the encoding support to encode the object with the provided encoding
1771
- */
1772
- Encode = 0,
1773
- /**
1774
- * Instructs the encoding support to decode the object with the provided encoding
1775
- */
1776
- Decode = 1
1777
- }
1778
- interface IEncodingSupport {
1779
- /**
1780
- * Gets the encoding of the object if known.
1781
- */
1782
- getEncoding(): string | undefined;
1783
- /**
1784
- * Sets the encoding for the object for saving.
1785
- */
1786
- setEncoding(encoding: string, mode: EncodingMode): Promise<void>;
1787
- }
1788
- interface ILanguageSupport {
1789
- /**
1790
- * Sets the language id of the object.
1791
- */
1792
- setLanguageId(languageId: string, source?: string): void;
1793
- }
1794
- interface ITextFileEditorModelSaveEvent extends IWorkingCopySaveEvent {
1795
- /**
1796
- * The resolved stat from the save operation.
1797
- */
1798
- readonly stat: IFileStatWithMetadata;
1799
- }
1800
- interface ITextFileEditorModel extends ITextEditorModel, IEncodingSupport, ILanguageSupport, IWorkingCopy {
1801
- readonly onDidSave: Event<ITextFileEditorModelSaveEvent>;
1802
- readonly onDidSaveError: Event<void>;
1803
- readonly onDidChangeOrphaned: Event<void>;
1804
- readonly onDidChangeReadonly: Event<void>;
1805
- readonly onDidChangeEncoding: Event<void>;
1806
- hasState(state: TextFileEditorModelState): boolean;
1807
- joinState(state: TextFileEditorModelState.PENDING_SAVE): Promise<void>;
1808
- updatePreferredEncoding(encoding: string | undefined): void;
1809
- save(options?: ITextFileSaveOptions): Promise<boolean>;
1810
- revert(options?: IRevertOptions): Promise<void>;
1811
- resolve(options?: ITextFileResolveOptions): Promise<void>;
1812
- isDirty(): this is IResolvedTextFileEditorModel;
1813
- getLanguageId(): string | undefined;
1814
- isResolved(): this is IResolvedTextFileEditorModel;
1815
- }
1816
- interface IResolvedTextFileEditorModel extends ITextFileEditorModel {
1817
556
  readonly textEditorModel: ITextModel;
1818
- createSnapshot(): ITextSnapshot;
1819
557
  }
1820
558
 
1821
559
  type OpenEditor = (modelRef: IReference<IResolvedTextEditorModel>, options: IEditorOptions | undefined, sideBySide?: boolean) => Promise<ICodeEditor | undefined>;
1822
560
  declare function getServiceOverride(openEditor: OpenEditor): IEditorOverrideServices;
1823
561
 
1824
- export { IEditorOptions, IReference, IResolvedTextEditorModel, ITextFileEditorModel, OpenEditor, getServiceOverride as default };
562
+ export { IEditorOptions, IReference, IResolvedTextEditorModel, OpenEditor, getServiceOverride as default };