@codingame/monaco-vscode-api 1.79.10 → 1.79.12

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.
@@ -1,16 +1,21 @@
1
1
  import { S as ServiceIdentifier, a as ServicesAccessor } from './instantiation.js';
2
- import { E as Event, a as IDisposable, C as CancellationToken, d as IWaitUntil } from './event.js';
2
+ import { E as Event, a as IDisposable, C as CancellationToken } from './event.js';
3
3
  import { I as IJSONSchema } from './jsonSchema.js';
4
- import { q as ITextModel, P as Position, R as Range, S as Selection, v as IRange, E as EndOfLineSequence, u as IPosition, k as IMarkdownString, w as ISingleEditOperation, x as EditorAutoIndentStrategy, y as ITextEditorModel, z as ITextSnapshot, A as ITextBufferFactory } from './editorBrowser.js';
4
+ import { l as ITextModel, P as Position, R as Range, S as Selection, B as IRange, E as EndOfLineSequence, p as IPosition, q as IMarkdownString, C as ISingleEditOperation, D as EditorAutoIndentStrategy } from './editorBrowser.js';
5
5
  import { S as Severity$1 } from './severity.js';
6
+ import { q as VSBuffer, w as IRelativePattern } from './files.js';
6
7
  import { U as URI } from './uri.js';
7
- import { o as ISaveOptions, m as IRevertOptions, S as SaveReason, q as SaveSource } from './editor.js';
8
- import { V as VSBuffer, n as VSBufferReadable, o as VSBufferReadableStream, p as IFileStatWithMetadata, q as FileOperation, r as ReadableStream, s as IReadFileStreamOptions, t as IWriteFileOptions, u as IBaseFileStatWithMetadata, v as IFileReadLimits, w as IRelativePattern } from './files.js';
9
- import { a as IProgress, b as IProgressStep } from './progress.js';
10
8
  import { T as ThemeIcon } from './themables.js';
11
9
  import { E as ExtensionIdentifier } from './extensions.d2.ts';
12
10
 
13
11
  type TypeConstraint = string | Function;
12
+ /**
13
+ * Given an object with all optional properties, requires at least one to be defined.
14
+ * i.e. AtLeastOne<MyObject>;
15
+ */
16
+ type AtLeastOne<T, U = {
17
+ [K in keyof T]: Pick<T, K>;
18
+ }> = Partial<T> & U[keyof U];
14
19
 
15
20
  interface ICommandEvent {
16
21
  commandId: string;
@@ -2554,1102 +2559,6 @@ declare class NoOpProgress implements INotificationProgress {
2554
2559
  worked(value: number): void;
2555
2560
  }
2556
2561
 
2557
- declare const enum WorkingCopyCapabilities {
2558
- /**
2559
- * Signals no specific capability for the working copy.
2560
- */
2561
- None = 0,
2562
- /**
2563
- * Signals that the working copy requires
2564
- * additional input when saving, e.g. an
2565
- * associated path to save to.
2566
- */
2567
- Untitled = 2,
2568
- /**
2569
- * The working copy will not indicate that
2570
- * it is dirty and unsaved content will be
2571
- * discarded without prompting if closed.
2572
- */
2573
- Scratchpad = 4
2574
- }
2575
- /**
2576
- * Data to be associated with working copy backups. Use
2577
- * `IWorkingCopyBackupService.resolve(workingCopy)` to
2578
- * retrieve the backup when loading the working copy.
2579
- */
2580
- interface IWorkingCopyBackup {
2581
- /**
2582
- * Any serializable metadata to be associated with the backup.
2583
- */
2584
- meta?: IWorkingCopyBackupMeta;
2585
- /**
2586
- * The actual snapshot of the contents of the working copy at
2587
- * the time the backup was made.
2588
- */
2589
- content?: VSBufferReadable | VSBufferReadableStream;
2590
- }
2591
- /**
2592
- * Working copy backup metadata that can be associated
2593
- * with the backup.
2594
- *
2595
- * Some properties may be reserved as outlined here and
2596
- * cannot be used.
2597
- */
2598
- interface IWorkingCopyBackupMeta {
2599
- /**
2600
- * Any property needs to be serializable through JSON.
2601
- */
2602
- [key: string]: unknown;
2603
- /**
2604
- * `typeId` is a reserved property that cannot be used
2605
- * as backup metadata.
2606
- */
2607
- typeId?: never;
2608
- }
2609
- /**
2610
- * Every working copy has in common that it is identified by
2611
- * a resource `URI` and a `typeId`. There can only be one
2612
- * working copy registered with the same `URI` and `typeId`.
2613
- */
2614
- interface IWorkingCopyIdentifier {
2615
- /**
2616
- * The type identifier of the working copy for grouping
2617
- * working copies of the same domain together.
2618
- *
2619
- * There can only be one working copy for a given resource
2620
- * and type identifier.
2621
- */
2622
- readonly typeId: string;
2623
- /**
2624
- * The resource of the working copy must be unique for
2625
- * working copies of the same `typeId`.
2626
- */
2627
- readonly resource: URI;
2628
- }
2629
- interface IWorkingCopySaveEvent {
2630
- /**
2631
- * The reason why the working copy was saved.
2632
- */
2633
- readonly reason?: SaveReason;
2634
- /**
2635
- * The source of the working copy save request.
2636
- */
2637
- readonly source?: SaveSource;
2638
- }
2639
- /**
2640
- * A working copy is an abstract concept to unify handling of
2641
- * data that can be worked on (e.g. edited) in an editor.
2642
- *
2643
- *
2644
- * A working copy resource may be the backing store of the data
2645
- * (e.g. a file on disk), but that is not a requirement. If
2646
- * your working copy is file based, consider to use the
2647
- * `IFileWorkingCopy` instead that simplifies a lot of things
2648
- * when working with file based working copies.
2649
- */
2650
- interface IWorkingCopy extends IWorkingCopyIdentifier {
2651
- /**
2652
- * Human readable name of the working copy.
2653
- */
2654
- readonly name: string;
2655
- /**
2656
- * The capabilities of the working copy.
2657
- */
2658
- readonly capabilities: WorkingCopyCapabilities;
2659
- /**
2660
- * Used by the workbench to signal if the working copy
2661
- * is dirty or not. Typically a working copy is dirty
2662
- * once changed until saved or reverted.
2663
- */
2664
- readonly onDidChangeDirty: Event<void>;
2665
- /**
2666
- * Used by the workbench e.g. to trigger auto-save
2667
- * (unless this working copy is untitled) and backups.
2668
- */
2669
- readonly onDidChangeContent: Event<void>;
2670
- /**
2671
- * Used by the workbench e.g. to track local history
2672
- * (unless this working copy is untitled).
2673
- */
2674
- readonly onDidSave: Event<IWorkingCopySaveEvent>;
2675
- /**
2676
- * Indicates that the file has unsaved changes
2677
- * and should confirm before closing.
2678
- */
2679
- isDirty(): boolean;
2680
- /**
2681
- * Indicates that the file has unsaved changes.
2682
- * Used for backup tracking and accounts for
2683
- * working copies that are never dirty e.g.
2684
- * scratchpads.
2685
- */
2686
- isModified(): boolean;
2687
- /**
2688
- * The workbench may call this method often after it receives
2689
- * the `onDidChangeContent` event for the working copy. The motivation
2690
- * is to allow to quit VSCode with dirty working copies present.
2691
- *
2692
- * Providers of working copies should use `IWorkingCopyBackupService.resolve(workingCopy)`
2693
- * to retrieve the backup metadata associated when loading the working copy.
2694
- *
2695
- * @param token support for cancellation
2696
- */
2697
- backup(token: CancellationToken): Promise<IWorkingCopyBackup>;
2698
- /**
2699
- * Asks the working copy to save. If the working copy was dirty, it is
2700
- * expected to be non-dirty after this operation has finished.
2701
- *
2702
- * @returns `true` if the operation was successful and `false` otherwise.
2703
- */
2704
- save(options?: ISaveOptions): Promise<boolean>;
2705
- /**
2706
- * Asks the working copy to revert. If the working copy was dirty, it is
2707
- * expected to be non-dirty after this operation has finished.
2708
- */
2709
- revert(options?: IRevertOptions): Promise<void>;
2710
- }
2711
-
2712
- interface IUntitledTextEditorModel extends ITextEditorModel, ILanguageSupport, IEncodingSupport, IWorkingCopy {
2713
- /**
2714
- * Emits an event when the encoding of this untitled model changes.
2715
- */
2716
- readonly onDidChangeEncoding: Event<void>;
2717
- /**
2718
- * Emits an event when the name of this untitled model changes.
2719
- */
2720
- readonly onDidChangeName: Event<void>;
2721
- /**
2722
- * Emits an event when this untitled model is reverted.
2723
- */
2724
- readonly onDidRevert: Event<void>;
2725
- /**
2726
- * Whether this untitled text model has an associated file path.
2727
- */
2728
- readonly hasAssociatedFilePath: boolean;
2729
- /**
2730
- * Whether this model has an explicit language or not.
2731
- */
2732
- readonly hasLanguageSetExplicitly: boolean;
2733
- /**
2734
- * Sets the encoding to use for this untitled model.
2735
- */
2736
- setEncoding(encoding: string): Promise<void>;
2737
- /**
2738
- * Resolves the untitled model.
2739
- */
2740
- resolve(): Promise<void>;
2741
- }
2742
-
2743
- interface INewUntitledTextEditorOptions {
2744
- /**
2745
- * Initial value of the untitled editor. An untitled editor with initial
2746
- * value is dirty right from the beginning.
2747
- */
2748
- initialValue?: string;
2749
- /**
2750
- * Preferred language id to use when saving the untitled editor.
2751
- */
2752
- languageId?: string;
2753
- /**
2754
- * Preferred encoding to use when saving the untitled editor.
2755
- */
2756
- encoding?: string;
2757
- }
2758
- interface IExistingUntitledTextEditorOptions extends INewUntitledTextEditorOptions {
2759
- /**
2760
- * A resource to identify the untitled editor to create or return
2761
- * if already existing.
2762
- *
2763
- * Note: the resource will not be used unless the scheme is `untitled`.
2764
- */
2765
- untitledResource?: URI;
2766
- }
2767
- interface INewUntitledTextEditorWithAssociatedResourceOptions extends INewUntitledTextEditorOptions {
2768
- /**
2769
- * Resource components to associate with the untitled editor. When saving
2770
- * the untitled editor, the associated components will be used and the user
2771
- * is not being asked to provide a file path.
2772
- *
2773
- * Note: currently it is not possible to specify the `scheme` to use. The
2774
- * untitled editor will saved to the default local or remote resource.
2775
- */
2776
- associatedResource?: {
2777
- authority: string;
2778
- path: string;
2779
- query: string;
2780
- fragment: string;
2781
- };
2782
- }
2783
- interface IUntitledTextEditorModelManager {
2784
- /**
2785
- * Events for when untitled text editors change (e.g. getting dirty, saved or reverted).
2786
- */
2787
- readonly onDidChangeDirty: Event<IUntitledTextEditorModel>;
2788
- /**
2789
- * Events for when untitled text editor encodings change.
2790
- */
2791
- readonly onDidChangeEncoding: Event<IUntitledTextEditorModel>;
2792
- /**
2793
- * Events for when untitled text editor labels change.
2794
- */
2795
- readonly onDidChangeLabel: Event<IUntitledTextEditorModel>;
2796
- /**
2797
- * Events for when untitled text editors are about to be disposed.
2798
- */
2799
- readonly onWillDispose: Event<IUntitledTextEditorModel>;
2800
- /**
2801
- * Creates a new untitled editor model with the provided options. If the `untitledResource`
2802
- * property is provided and the untitled editor exists, it will return that existing
2803
- * instance instead of creating a new one.
2804
- */
2805
- create(options?: INewUntitledTextEditorOptions): IUntitledTextEditorModel;
2806
- create(options?: INewUntitledTextEditorWithAssociatedResourceOptions): IUntitledTextEditorModel;
2807
- create(options?: IExistingUntitledTextEditorOptions): IUntitledTextEditorModel;
2808
- /**
2809
- * Returns an existing untitled editor model if already created before.
2810
- */
2811
- get(resource: URI): IUntitledTextEditorModel | undefined;
2812
- /**
2813
- * Returns the value of the untitled editor, undefined if none exists
2814
- * @param resource The URI of the untitled file
2815
- * @returns The content, or undefined
2816
- */
2817
- getValue(resource: URI): string | undefined;
2818
- /**
2819
- * Resolves an untitled editor model from the provided options. If the `untitledResource`
2820
- * property is provided and the untitled editor exists, it will return that existing
2821
- * instance instead of creating a new one.
2822
- */
2823
- resolve(options?: INewUntitledTextEditorOptions): Promise<IUntitledTextEditorModel>;
2824
- resolve(options?: INewUntitledTextEditorWithAssociatedResourceOptions): Promise<IUntitledTextEditorModel>;
2825
- resolve(options?: IExistingUntitledTextEditorOptions): Promise<IUntitledTextEditorModel>;
2826
- /**
2827
- * Figures out if the given resource has an associated resource or not.
2828
- */
2829
- isUntitledWithAssociatedResource(resource: URI): boolean;
2830
- }
2831
-
2832
- /**
2833
- * A resource based `IWorkingCopy` is backed by a `URI` from a
2834
- * known file system provider.
2835
- */
2836
- interface IResourceWorkingCopy extends IWorkingCopy, IDisposable {
2837
- /**
2838
- * An event for when the orphaned state of the resource working copy changes.
2839
- */
2840
- readonly onDidChangeOrphaned: Event<void>;
2841
- /**
2842
- * Whether the resource working copy is orphaned or not.
2843
- */
2844
- isOrphaned(): boolean;
2845
- /**
2846
- * An event for when the file working copy has been disposed.
2847
- */
2848
- readonly onWillDispose: Event<void>;
2849
- /**
2850
- * Whether the file working copy has been disposed or not.
2851
- */
2852
- isDisposed(): boolean;
2853
- }
2854
-
2855
- /**
2856
- * A generic file working copy model to be reused by untitled
2857
- * and stored file working copies.
2858
- */
2859
- interface IFileWorkingCopyModel extends IDisposable {
2860
- /**
2861
- * This event signals ANY changes to the contents, for example:
2862
- * - through the user typing into the editor
2863
- * - from API usage (e.g. bulk edits)
2864
- * - when `IFileWorkingCopyModel#update` is invoked with contents
2865
- * that are different from the current contents
2866
- *
2867
- * The file working copy will listen to these changes and may mark
2868
- * the working copy as dirty whenever this event fires.
2869
- *
2870
- * Note: ONLY report changes to the model but not the underlying
2871
- * file. The file working copy is tracking changes to the file
2872
- * automatically.
2873
- */
2874
- readonly onDidChangeContent: Event<unknown>;
2875
- /**
2876
- * An event emitted right before disposing the model.
2877
- */
2878
- readonly onWillDispose: Event<void>;
2879
- /**
2880
- * Snapshots the model's current content for writing. This must include
2881
- * any changes that were made to the model that are in memory.
2882
- *
2883
- * @param token support for cancellation
2884
- */
2885
- snapshot(token: CancellationToken): Promise<VSBufferReadableStream>;
2886
- /**
2887
- * Updates the model with the provided contents. The implementation should
2888
- * behave in a similar fashion as `IFileWorkingCopyModelFactory#createModel`
2889
- * except that here the model already exists and just needs to update to
2890
- * the provided contents.
2891
- *
2892
- * Note: it is expected that the model fires a `onDidChangeContent` event
2893
- * as part of the update.
2894
- *
2895
- * @param contents the contents to use for the model
2896
- * @param token support for cancellation
2897
- */
2898
- update(contents: VSBufferReadableStream, token: CancellationToken): Promise<void>;
2899
- }
2900
- interface IFileWorkingCopy<M extends IFileWorkingCopyModel> extends IWorkingCopy, IDisposable {
2901
- /**
2902
- * An event for when the file working copy has been reverted.
2903
- */
2904
- readonly onDidRevert: Event<void>;
2905
- /**
2906
- * An event for when the file working copy has been disposed.
2907
- */
2908
- readonly onWillDispose: Event<void>;
2909
- /**
2910
- * Provides access to the underlying model of this file
2911
- * based working copy. As long as the file working copy
2912
- * has not been resolved, the model is `undefined`.
2913
- */
2914
- readonly model: M | undefined;
2915
- /**
2916
- * Resolves the file working copy and thus makes the `model`
2917
- * available.
2918
- */
2919
- resolve(): Promise<void>;
2920
- /**
2921
- * Whether we have a resolved model or not.
2922
- */
2923
- isResolved(): this is IResolvedFileWorkingCopy<M>;
2924
- }
2925
- interface IResolvedFileWorkingCopy<M extends IFileWorkingCopyModel> extends IFileWorkingCopy<M> {
2926
- /**
2927
- * A resolved file working copy has a resolved model.
2928
- */
2929
- readonly model: M;
2930
- }
2931
-
2932
- /**
2933
- * The underlying model of a stored file working copy provides some
2934
- * methods for the stored file working copy to function. The model is
2935
- * typically only available after the working copy has been
2936
- * resolved via it's `resolve()` method.
2937
- */
2938
- interface IStoredFileWorkingCopyModel extends IFileWorkingCopyModel {
2939
- readonly onDidChangeContent: Event<IStoredFileWorkingCopyModelContentChangedEvent>;
2940
- /**
2941
- * A version ID of the model. If a `onDidChangeContent` is fired
2942
- * from the model and the last known saved `versionId` matches
2943
- * with the `model.versionId`, the stored file working copy will
2944
- * discard any dirty state.
2945
- *
2946
- * A use case is the following:
2947
- * - a stored file working copy gets edited and thus dirty
2948
- * - the user triggers undo to revert the changes
2949
- * - at this point the `versionId` should match the one we had saved
2950
- *
2951
- * This requires the model to be aware of undo/redo operations.
2952
- */
2953
- readonly versionId: unknown;
2954
- /**
2955
- * Close the current undo-redo element. This offers a way
2956
- * to create an undo/redo stop point.
2957
- *
2958
- * This method may for example be called right before the
2959
- * save is triggered so that the user can always undo back
2960
- * to the state before saving.
2961
- */
2962
- pushStackElement(): void;
2963
- }
2964
- interface IStoredFileWorkingCopyModelContentChangedEvent {
2965
- /**
2966
- * Flag that indicates that this event was generated while undoing.
2967
- */
2968
- readonly isUndoing: boolean;
2969
- /**
2970
- * Flag that indicates that this event was generated while redoing.
2971
- */
2972
- readonly isRedoing: boolean;
2973
- }
2974
- /**
2975
- * A stored file based `IWorkingCopy` is backed by a `URI` from a
2976
- * known file system provider. Given this assumption, a lot
2977
- * of functionality can be built on top, such as saving in
2978
- * a secure way to prevent data loss.
2979
- */
2980
- interface IStoredFileWorkingCopy<M extends IStoredFileWorkingCopyModel> extends IResourceWorkingCopy, IFileWorkingCopy<M> {
2981
- /**
2982
- * An event for when a stored file working copy was resolved.
2983
- */
2984
- readonly onDidResolve: Event<void>;
2985
- /**
2986
- * An event for when a stored file working copy was saved successfully.
2987
- */
2988
- readonly onDidSave: Event<IStoredFileWorkingCopySaveEvent>;
2989
- /**
2990
- * An event indicating that a stored file working copy save operation failed.
2991
- */
2992
- readonly onDidSaveError: Event<void>;
2993
- /**
2994
- * An event for when the readonly state of the stored file working copy changes.
2995
- */
2996
- readonly onDidChangeReadonly: Event<void>;
2997
- /**
2998
- * Resolves a stored file working copy.
2999
- */
3000
- resolve(options?: IStoredFileWorkingCopyResolveOptions): Promise<void>;
3001
- /**
3002
- * Explicitly sets the working copy to be modified.
3003
- */
3004
- markModified(): void;
3005
- /**
3006
- * Whether the stored file working copy is in the provided `state`
3007
- * or not.
3008
- *
3009
- * @param state the `FileWorkingCopyState` to check on.
3010
- */
3011
- hasState(state: StoredFileWorkingCopyState): boolean;
3012
- /**
3013
- * Allows to join a state change away from the provided `state`.
3014
- *
3015
- * @param state currently only `FileWorkingCopyState.PENDING_SAVE`
3016
- * can be awaited on to resolve.
3017
- */
3018
- joinState(state: StoredFileWorkingCopyState.PENDING_SAVE): Promise<void>;
3019
- /**
3020
- * Whether we have a resolved model or not.
3021
- */
3022
- isResolved(): this is IResolvedStoredFileWorkingCopy<M>;
3023
- /**
3024
- * Whether the stored file working copy is readonly or not.
3025
- */
3026
- isReadonly(): boolean;
3027
- }
3028
- interface IResolvedStoredFileWorkingCopy<M extends IStoredFileWorkingCopyModel> extends IStoredFileWorkingCopy<M> {
3029
- /**
3030
- * A resolved stored file working copy has a resolved model.
3031
- */
3032
- readonly model: M;
3033
- }
3034
- /**
3035
- * States the stored file working copy can be in.
3036
- */
3037
- declare const enum StoredFileWorkingCopyState {
3038
- /**
3039
- * A stored file working copy is saved.
3040
- */
3041
- SAVED = 0,
3042
- /**
3043
- * A stored file working copy is dirty.
3044
- */
3045
- DIRTY = 1,
3046
- /**
3047
- * A stored file working copy is currently being saved but
3048
- * this operation has not completed yet.
3049
- */
3050
- PENDING_SAVE = 2,
3051
- /**
3052
- * A stored file working copy is in conflict mode when changes
3053
- * cannot be saved because the underlying file has changed.
3054
- * Stored file working copies in conflict mode are always dirty.
3055
- */
3056
- CONFLICT = 3,
3057
- /**
3058
- * A stored file working copy is in orphan state when the underlying
3059
- * file has been deleted.
3060
- */
3061
- ORPHAN = 4,
3062
- /**
3063
- * Any error that happens during a save that is not causing
3064
- * the `StoredFileWorkingCopyState.CONFLICT` state.
3065
- * Stored file working copies in error mode are always dirty.
3066
- */
3067
- ERROR = 5
3068
- }
3069
- interface IStoredFileWorkingCopyResolveOptions {
3070
- /**
3071
- * The contents to use for the stored file working copy if known. If not
3072
- * provided, the contents will be retrieved from the underlying
3073
- * resource or backup if present.
3074
- *
3075
- * If contents are provided, the stored file working copy will be marked
3076
- * as dirty right from the beginning.
3077
- */
3078
- readonly contents?: VSBufferReadableStream;
3079
- /**
3080
- * Go to disk bypassing any cache of the stored file working copy if any.
3081
- */
3082
- readonly forceReadFromFile?: boolean;
3083
- }
3084
- interface IStoredFileWorkingCopySaveEvent extends IWorkingCopySaveEvent {
3085
- /**
3086
- * The resolved stat from the save operation.
3087
- */
3088
- readonly stat: IFileStatWithMetadata;
3089
- }
3090
-
3091
- interface SourceTargetPair {
3092
- /**
3093
- * The source resource that is defined for move operations.
3094
- */
3095
- readonly source?: URI;
3096
- /**
3097
- * The target resource the event is about.
3098
- */
3099
- readonly target: URI;
3100
- }
3101
- interface IFileOperationUndoRedoInfo {
3102
- /**
3103
- * Id of the undo group that the file operation belongs to.
3104
- */
3105
- undoRedoGroupId?: number;
3106
- /**
3107
- * Flag indicates if the operation is an undo.
3108
- */
3109
- isUndoing?: boolean;
3110
- }
3111
- interface WorkingCopyFileEvent extends IWaitUntil {
3112
- /**
3113
- * An identifier to correlate the operation through the
3114
- * different event types (before, after, error).
3115
- */
3116
- readonly correlationId: number;
3117
- /**
3118
- * The file operation that is taking place.
3119
- */
3120
- readonly operation: FileOperation;
3121
- /**
3122
- * The array of source/target pair of files involved in given operation.
3123
- */
3124
- readonly files: readonly SourceTargetPair[];
3125
- }
3126
- interface IWorkingCopyFileOperationParticipant {
3127
- /**
3128
- * Participate in a file operation of working copies. Allows to
3129
- * change the working copies before they are being saved to disk.
3130
- */
3131
- participate(files: SourceTargetPair[], operation: FileOperation, undoInfo: IFileOperationUndoRedoInfo | undefined, timeout: number, token: CancellationToken): Promise<void>;
3132
- }
3133
- interface IStoredFileWorkingCopySaveParticipant {
3134
- /**
3135
- * Participate in a save operation of file stored working copies.
3136
- * Allows to make changes before content is being saved to disk.
3137
- */
3138
- participate(workingCopy: IStoredFileWorkingCopy<IStoredFileWorkingCopyModel>, context: {
3139
- reason: SaveReason;
3140
- }, progress: IProgress<IProgressStep>, token: CancellationToken): Promise<void>;
3141
- }
3142
- interface ICreateOperation {
3143
- resource: URI;
3144
- overwrite?: boolean;
3145
- }
3146
- interface ICreateFileOperation extends ICreateOperation {
3147
- contents?: VSBuffer | VSBufferReadable | VSBufferReadableStream;
3148
- }
3149
- interface IDeleteOperation {
3150
- resource: URI;
3151
- useTrash?: boolean;
3152
- recursive?: boolean;
3153
- }
3154
- interface IMoveOperation {
3155
- file: Required<SourceTargetPair>;
3156
- overwrite?: boolean;
3157
- }
3158
- interface ICopyOperation extends IMoveOperation {
3159
- }
3160
- /**
3161
- * Returns the working copies for a given resource.
3162
- */
3163
- type WorkingCopyProvider = (resourceOrFolder: URI) => IWorkingCopy[];
3164
-
3165
- declare const IWorkingCopyFileService: ServiceIdentifier<IWorkingCopyFileService>;
3166
- /**
3167
- * A service that allows to perform file operations with working copy support.
3168
- * Any operation that would leave a stale dirty working copy behind will make
3169
- * sure to revert the working copy first.
3170
- *
3171
- * On top of that events are provided to participate in each state of the
3172
- * operation to perform additional work.
3173
- */
3174
- interface IWorkingCopyFileService {
3175
- readonly _serviceBrand: undefined;
3176
- /**
3177
- * An event that is fired when a certain working copy IO operation is about to run.
3178
- *
3179
- * Participants can join this event with a long running operation to keep some state
3180
- * before the operation is started, but working copies should not be changed at this
3181
- * point in time. For that purpose, use the `IWorkingCopyFileOperationParticipant` API.
3182
- */
3183
- readonly onWillRunWorkingCopyFileOperation: Event<WorkingCopyFileEvent>;
3184
- /**
3185
- * An event that is fired after a working copy IO operation has failed.
3186
- *
3187
- * Participants can join this event with a long running operation to clean up as needed.
3188
- */
3189
- readonly onDidFailWorkingCopyFileOperation: Event<WorkingCopyFileEvent>;
3190
- /**
3191
- * An event that is fired after a working copy IO operation has been performed.
3192
- *
3193
- * Participants can join this event with a long running operation to make changes
3194
- * after the operation has finished.
3195
- */
3196
- readonly onDidRunWorkingCopyFileOperation: Event<WorkingCopyFileEvent>;
3197
- /**
3198
- * Adds a participant for file operations on working copies.
3199
- */
3200
- addFileOperationParticipant(participant: IWorkingCopyFileOperationParticipant): IDisposable;
3201
- /**
3202
- * Whether save participants are present for stored file working copies.
3203
- */
3204
- get hasSaveParticipants(): boolean;
3205
- /**
3206
- * Adds a participant for save operations on stored file working copies.
3207
- */
3208
- addSaveParticipant(participant: IStoredFileWorkingCopySaveParticipant): IDisposable;
3209
- /**
3210
- * Runs all available save participants for stored file working copies.
3211
- */
3212
- runSaveParticipants(workingCopy: IStoredFileWorkingCopy<IStoredFileWorkingCopyModel>, context: {
3213
- reason: SaveReason;
3214
- }, token: CancellationToken): Promise<void>;
3215
- /**
3216
- * Will create a resource with the provided optional contents, optionally overwriting any target.
3217
- *
3218
- * Working copy owners can listen to the `onWillRunWorkingCopyFileOperation` and
3219
- * `onDidRunWorkingCopyFileOperation` events to participate.
3220
- */
3221
- create(operations: ICreateFileOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<readonly IFileStatWithMetadata[]>;
3222
- /**
3223
- * Will create a folder and any parent folder that needs to be created.
3224
- *
3225
- * Working copy owners can listen to the `onWillRunWorkingCopyFileOperation` and
3226
- * `onDidRunWorkingCopyFileOperation` events to participate.
3227
- *
3228
- * Note: events will only be emitted for the provided resource, but not any
3229
- * parent folders that are being created as part of the operation.
3230
- */
3231
- createFolder(operations: ICreateOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<readonly IFileStatWithMetadata[]>;
3232
- /**
3233
- * Will move working copies matching the provided resources and corresponding children
3234
- * to the target resources using the associated file service for those resources.
3235
- *
3236
- * Working copy owners can listen to the `onWillRunWorkingCopyFileOperation` and
3237
- * `onDidRunWorkingCopyFileOperation` events to participate.
3238
- */
3239
- move(operations: IMoveOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<readonly IFileStatWithMetadata[]>;
3240
- /**
3241
- * Will copy working copies matching the provided resources and corresponding children
3242
- * to the target resources using the associated file service for those resources.
3243
- *
3244
- * Working copy owners can listen to the `onWillRunWorkingCopyFileOperation` and
3245
- * `onDidRunWorkingCopyFileOperation` events to participate.
3246
- */
3247
- copy(operations: ICopyOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<readonly IFileStatWithMetadata[]>;
3248
- /**
3249
- * Will delete working copies matching the provided resources and children
3250
- * using the associated file service for those resources.
3251
- *
3252
- * Working copy owners can listen to the `onWillRunWorkingCopyFileOperation` and
3253
- * `onDidRunWorkingCopyFileOperation` events to participate.
3254
- */
3255
- delete(operations: IDeleteOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<void>;
3256
- /**
3257
- * Register a new provider for working copies based on a resource.
3258
- *
3259
- * @return a disposable that unregisters the provider.
3260
- */
3261
- registerWorkingCopyProvider(provider: WorkingCopyProvider): IDisposable;
3262
- /**
3263
- * Will return all working copies that are dirty matching the provided resource.
3264
- * If the resource is a folder and the scheme supports file operations, a working
3265
- * copy that is dirty and is a child of that folder will also be returned.
3266
- */
3267
- getDirty(resource: URI): readonly IWorkingCopy[];
3268
- }
3269
-
3270
- declare const ITextFileService: ServiceIdentifier<ITextFileService>;
3271
- interface ITextFileService extends IDisposable {
3272
- readonly _serviceBrand: undefined;
3273
- /**
3274
- * Access to the manager of text file editor models providing further
3275
- * methods to work with them.
3276
- */
3277
- readonly files: ITextFileEditorModelManager;
3278
- /**
3279
- * Access to the manager of untitled text editor models providing further
3280
- * methods to work with them.
3281
- */
3282
- readonly untitled: IUntitledTextEditorModelManager;
3283
- /**
3284
- * Helper to determine encoding for resources.
3285
- */
3286
- readonly encoding: IResourceEncodings;
3287
- /**
3288
- * A resource is dirty if it has unsaved changes or is an untitled file not yet saved.
3289
- *
3290
- * @param resource the resource to check for being dirty
3291
- */
3292
- isDirty(resource: URI): boolean;
3293
- /**
3294
- * Saves the resource.
3295
- *
3296
- * @param resource the resource to save
3297
- * @param options optional save options
3298
- * @return Path of the saved resource or undefined if canceled.
3299
- */
3300
- save(resource: URI, options?: ITextFileSaveOptions): Promise<URI | undefined>;
3301
- /**
3302
- * Saves the provided resource asking the user for a file name or using the provided one.
3303
- *
3304
- * @param resource the resource to save as.
3305
- * @param targetResource the optional target to save to.
3306
- * @param options optional save options
3307
- * @return Path of the saved resource or undefined if canceled.
3308
- */
3309
- saveAs(resource: URI, targetResource?: URI, options?: ITextFileSaveAsOptions): Promise<URI | undefined>;
3310
- /**
3311
- * Reverts the provided resource.
3312
- *
3313
- * @param resource the resource of the file to revert.
3314
- * @param force to force revert even when the file is not dirty
3315
- */
3316
- revert(resource: URI, options?: IRevertOptions): Promise<void>;
3317
- /**
3318
- * Read the contents of a file identified by the resource.
3319
- */
3320
- read(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileContent>;
3321
- /**
3322
- * Read the contents of a file identified by the resource as stream.
3323
- */
3324
- readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent>;
3325
- /**
3326
- * Update a file with given contents.
3327
- */
3328
- write(resource: URI, value: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise<IFileStatWithMetadata>;
3329
- /**
3330
- * Create files. If the file exists it will be overwritten with the contents if
3331
- * the options enable to overwrite.
3332
- */
3333
- create(operations: {
3334
- resource: URI;
3335
- value?: string | ITextSnapshot;
3336
- options?: {
3337
- overwrite?: boolean;
3338
- };
3339
- }[], undoInfo?: IFileOperationUndoRedoInfo): Promise<readonly IFileStatWithMetadata[]>;
3340
- /**
3341
- * Returns the readable that uses the appropriate encoding. This method should
3342
- * be used whenever a `string` or `ITextSnapshot` is being persisted to the
3343
- * file system.
3344
- */
3345
- getEncodedReadable(resource: URI, value: ITextSnapshot, options?: IWriteTextFileOptions): Promise<VSBufferReadable>;
3346
- getEncodedReadable(resource: URI, value: string, options?: IWriteTextFileOptions): Promise<VSBuffer>;
3347
- getEncodedReadable(resource: URI, value?: ITextSnapshot, options?: IWriteTextFileOptions): Promise<VSBufferReadable | undefined>;
3348
- getEncodedReadable(resource: URI, value?: string, options?: IWriteTextFileOptions): Promise<VSBuffer | undefined>;
3349
- getEncodedReadable(resource: URI, value?: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise<VSBuffer | VSBufferReadable | undefined>;
3350
- /**
3351
- * Returns a stream of strings that uses the appropriate encoding. This method should
3352
- * be used whenever a `VSBufferReadableStream` is being loaded from the file system.
3353
- *
3354
- * Will throw an error if `acceptTextOnly: true` for resources that seem to be binary.
3355
- */
3356
- getDecodedStream(resource: URI, value: VSBufferReadableStream, options?: IReadTextFileEncodingOptions): Promise<ReadableStream<string>>;
3357
- }
3358
- interface IReadTextFileEncodingOptions {
3359
- /**
3360
- * The optional encoding parameter allows to specify the desired encoding when resolving
3361
- * the contents of the file.
3362
- */
3363
- readonly encoding?: string;
3364
- /**
3365
- * The optional guessEncoding parameter allows to guess encoding from content of the file.
3366
- */
3367
- readonly autoGuessEncoding?: boolean;
3368
- /**
3369
- * The optional acceptTextOnly parameter allows to fail this request early if the file
3370
- * contents are not textual.
3371
- */
3372
- readonly acceptTextOnly?: boolean;
3373
- }
3374
- interface IReadTextFileOptions extends IReadTextFileEncodingOptions, IReadFileStreamOptions {
3375
- }
3376
- interface IWriteTextFileOptions extends IWriteFileOptions {
3377
- /**
3378
- * The encoding to use when updating a file.
3379
- */
3380
- readonly encoding?: string;
3381
- /**
3382
- * Whether to write to the file as elevated (admin) user. When setting this option a prompt will
3383
- * ask the user to authenticate as super user.
3384
- */
3385
- readonly writeElevated?: boolean;
3386
- }
3387
- interface IResourceEncodings {
3388
- getPreferredReadEncoding(resource: URI): Promise<IResourceEncoding>;
3389
- getPreferredWriteEncoding(resource: URI, preferredEncoding?: string): Promise<IResourceEncoding>;
3390
- }
3391
- interface IResourceEncoding {
3392
- readonly encoding: string;
3393
- readonly hasBOM: boolean;
3394
- }
3395
- /**
3396
- * The save error handler can be installed on the text file editor model to install code that executes when save errors occur.
3397
- */
3398
- interface ISaveErrorHandler {
3399
- /**
3400
- * Called whenever a save fails.
3401
- */
3402
- onSaveError(error: Error, model: ITextFileEditorModel): void;
3403
- }
3404
- /**
3405
- * States the text file editor model can be in.
3406
- */
3407
- declare const enum TextFileEditorModelState {
3408
- /**
3409
- * A model is saved.
3410
- */
3411
- SAVED = 0,
3412
- /**
3413
- * A model is dirty.
3414
- */
3415
- DIRTY = 1,
3416
- /**
3417
- * A model is currently being saved but this operation has not completed yet.
3418
- */
3419
- PENDING_SAVE = 2,
3420
- /**
3421
- * A model is in conflict mode when changes cannot be saved because the
3422
- * underlying file has changed. Models in conflict mode are always dirty.
3423
- */
3424
- CONFLICT = 3,
3425
- /**
3426
- * A model is in orphan state when the underlying file has been deleted.
3427
- */
3428
- ORPHAN = 4,
3429
- /**
3430
- * Any error that happens during a save that is not causing the CONFLICT state.
3431
- * Models in error mode are always dirty.
3432
- */
3433
- ERROR = 5
3434
- }
3435
- declare const enum TextFileResolveReason {
3436
- EDITOR = 1,
3437
- REFERENCE = 2,
3438
- OTHER = 3
3439
- }
3440
- interface IBaseTextFileContent extends IBaseFileStatWithMetadata {
3441
- /**
3442
- * The encoding of the content if known.
3443
- */
3444
- readonly encoding: string;
3445
- }
3446
- interface ITextFileContent extends IBaseTextFileContent {
3447
- /**
3448
- * The content of a text file.
3449
- */
3450
- readonly value: string;
3451
- }
3452
- interface ITextFileStreamContent extends IBaseTextFileContent {
3453
- /**
3454
- * The line grouped content of a text file.
3455
- */
3456
- readonly value: ITextBufferFactory;
3457
- }
3458
- interface ITextFileEditorModelResolveOrCreateOptions extends ITextFileResolveOptions {
3459
- /**
3460
- * The language id to use for the model text content.
3461
- */
3462
- readonly languageId?: string;
3463
- /**
3464
- * The encoding to use when resolving the model text content.
3465
- */
3466
- readonly encoding?: string;
3467
- /**
3468
- * If the model was already resolved before, allows to trigger
3469
- * a reload of it to fetch the latest contents.
3470
- */
3471
- readonly reload?: {
3472
- /**
3473
- * Controls whether the reload happens in the background
3474
- * or whether `resolve` will await the reload to happen.
3475
- */
3476
- readonly async: boolean;
3477
- };
3478
- }
3479
- interface ITextFileSaveEvent extends ITextFileEditorModelSaveEvent {
3480
- /**
3481
- * The model that was saved.
3482
- */
3483
- readonly model: ITextFileEditorModel;
3484
- }
3485
- interface ITextFileResolveEvent {
3486
- /**
3487
- * The model that was resolved.
3488
- */
3489
- readonly model: ITextFileEditorModel;
3490
- /**
3491
- * The reason why the model was resolved.
3492
- */
3493
- readonly reason: TextFileResolveReason;
3494
- }
3495
- interface ITextFileSaveParticipant {
3496
- /**
3497
- * Participate in a save of a model. Allows to change the model
3498
- * before it is being saved to disk.
3499
- */
3500
- participate(model: ITextFileEditorModel, context: {
3501
- reason: SaveReason;
3502
- }, progress: IProgress<IProgressStep>, token: CancellationToken): Promise<void>;
3503
- }
3504
- interface ITextFileEditorModelManager {
3505
- readonly onDidCreate: Event<ITextFileEditorModel>;
3506
- readonly onDidResolve: Event<ITextFileResolveEvent>;
3507
- readonly onDidChangeDirty: Event<ITextFileEditorModel>;
3508
- readonly onDidChangeReadonly: Event<ITextFileEditorModel>;
3509
- readonly onDidRemove: Event<URI>;
3510
- readonly onDidChangeOrphaned: Event<ITextFileEditorModel>;
3511
- readonly onDidChangeEncoding: Event<ITextFileEditorModel>;
3512
- readonly onDidSaveError: Event<ITextFileEditorModel>;
3513
- readonly onDidSave: Event<ITextFileSaveEvent>;
3514
- readonly onDidRevert: Event<ITextFileEditorModel>;
3515
- /**
3516
- * Access to all text file editor models in memory.
3517
- */
3518
- readonly models: ITextFileEditorModel[];
3519
- /**
3520
- * Allows to configure the error handler that is called on save errors.
3521
- */
3522
- saveErrorHandler: ISaveErrorHandler;
3523
- /**
3524
- * Returns the text file editor model for the provided resource
3525
- * or undefined if none.
3526
- */
3527
- get(resource: URI): ITextFileEditorModel | undefined;
3528
- /**
3529
- * Allows to resolve a text file model from disk.
3530
- */
3531
- resolve(resource: URI, options?: ITextFileEditorModelResolveOrCreateOptions): Promise<ITextFileEditorModel>;
3532
- /**
3533
- * Adds a participant for saving text file models.
3534
- */
3535
- addSaveParticipant(participant: ITextFileSaveParticipant): IDisposable;
3536
- /**
3537
- * Runs the registered save participants on the provided model.
3538
- */
3539
- runSaveParticipants(model: ITextFileEditorModel, context: {
3540
- reason: SaveReason;
3541
- }, token: CancellationToken): Promise<void>;
3542
- /**
3543
- * Waits for the model to be ready to be disposed. There may be conditions
3544
- * under which the model cannot be disposed, e.g. when it is dirty. Once the
3545
- * promise is settled, it is safe to dispose the model.
3546
- */
3547
- canDispose(model: ITextFileEditorModel): true | Promise<true>;
3548
- }
3549
- interface ITextFileSaveOptions extends ISaveOptions {
3550
- /**
3551
- * Save the file with an attempt to unlock it.
3552
- */
3553
- readonly writeUnlock?: boolean;
3554
- /**
3555
- * Save the file with elevated privileges.
3556
- *
3557
- * Note: This may not be supported in all environments.
3558
- */
3559
- readonly writeElevated?: boolean;
3560
- /**
3561
- * Allows to write to a file even if it has been modified on disk.
3562
- */
3563
- readonly ignoreModifiedSince?: boolean;
3564
- /**
3565
- * If set, will bubble up the error to the caller instead of handling it.
3566
- */
3567
- readonly ignoreErrorHandler?: boolean;
3568
- }
3569
- interface ITextFileSaveAsOptions extends ITextFileSaveOptions {
3570
- /**
3571
- * Optional URI to use as suggested file path to save as.
3572
- */
3573
- readonly suggestedTarget?: URI;
3574
- }
3575
- interface ITextFileResolveOptions {
3576
- /**
3577
- * The contents to use for the model if known. If not
3578
- * provided, the contents will be retrieved from the
3579
- * underlying resource or backup if present.
3580
- */
3581
- readonly contents?: ITextBufferFactory;
3582
- /**
3583
- * Go to file bypassing any cache of the model if any.
3584
- */
3585
- readonly forceReadFromFile?: boolean;
3586
- /**
3587
- * Allow to resolve a model even if we think it is a binary file.
3588
- */
3589
- readonly allowBinary?: boolean;
3590
- /**
3591
- * Context why the model is being resolved.
3592
- */
3593
- readonly reason?: TextFileResolveReason;
3594
- /**
3595
- * If provided, the size of the file will be checked against the limits
3596
- * and an error will be thrown if any limit is exceeded.
3597
- */
3598
- readonly limits?: IFileReadLimits;
3599
- }
3600
- declare const enum EncodingMode {
3601
- /**
3602
- * Instructs the encoding support to encode the object with the provided encoding
3603
- */
3604
- Encode = 0,
3605
- /**
3606
- * Instructs the encoding support to decode the object with the provided encoding
3607
- */
3608
- Decode = 1
3609
- }
3610
- interface IEncodingSupport {
3611
- /**
3612
- * Gets the encoding of the object if known.
3613
- */
3614
- getEncoding(): string | undefined;
3615
- /**
3616
- * Sets the encoding for the object for saving.
3617
- */
3618
- setEncoding(encoding: string, mode: EncodingMode): Promise<void>;
3619
- }
3620
- interface ILanguageSupport {
3621
- /**
3622
- * Sets the language id of the object.
3623
- */
3624
- setLanguageId(languageId: string, source?: string): void;
3625
- }
3626
- interface ITextFileEditorModelSaveEvent extends IWorkingCopySaveEvent {
3627
- /**
3628
- * The resolved stat from the save operation.
3629
- */
3630
- readonly stat: IFileStatWithMetadata;
3631
- }
3632
- interface ITextFileEditorModel extends ITextEditorModel, IEncodingSupport, ILanguageSupport, IWorkingCopy {
3633
- readonly onDidSave: Event<ITextFileEditorModelSaveEvent>;
3634
- readonly onDidSaveError: Event<void>;
3635
- readonly onDidChangeOrphaned: Event<void>;
3636
- readonly onDidChangeReadonly: Event<void>;
3637
- readonly onDidChangeEncoding: Event<void>;
3638
- hasState(state: TextFileEditorModelState): boolean;
3639
- joinState(state: TextFileEditorModelState.PENDING_SAVE): Promise<void>;
3640
- updatePreferredEncoding(encoding: string | undefined): void;
3641
- save(options?: ITextFileSaveOptions): Promise<boolean>;
3642
- revert(options?: IRevertOptions): Promise<void>;
3643
- resolve(options?: ITextFileResolveOptions): Promise<void>;
3644
- isDirty(): this is IResolvedTextFileEditorModel;
3645
- getLanguageId(): string | undefined;
3646
- isResolved(): this is IResolvedTextFileEditorModel;
3647
- }
3648
- interface IResolvedTextFileEditorModel extends ITextFileEditorModel {
3649
- readonly textEditorModel: ITextModel;
3650
- createSnapshot(): ITextSnapshot;
3651
- }
3652
-
3653
2562
  type ColorIdentifier = string;
3654
2563
  declare const enum ColorTransformType {
3655
2564
  Darken = 0,
@@ -3780,4 +2689,4 @@ interface ILanguageFeaturesService {
3780
2689
  setNotebookTypeResolver(resolver: NotebookInfoResolver | undefined): void;
3781
2690
  }
3782
2691
 
3783
- export { INotificationHandle as A, IPromptChoice as B, CommandsRegistry as C, IPromptChoiceWithMenu as D, IPromptOptions as E, FoldingRangeProvider as F, IStatusMessageOptions as G, NoOpNotification as H, ILanguageFeaturesService as I, NoOpProgress as J, LanguageFeatureRegistry as L, NotificationsFilter as N, SubmenuAction as S, TextEdit as T, WorkspaceEdit as W, ILanguageConfigurationService as a, INotificationService as b, ITextFileEditorModel as c, ILanguageIdCodec as d, IAction as e, ICommandService as f, ColorIdentifier as g, Color as h, LanguageSelector as i, Command as j, IInplaceReplaceSupportResult as k, WorkspaceEditMetadata as l, IActionRunner as m, IMarkerService as n, ITextFileService as o, IWorkingCopyFileService as p, NotificationMessage as q, registerColor as r, NotificationPriority as s, INotificationProperties as t, NeverShowAgainScope as u, INeverShowAgainOptions as v, INotification as w, INotificationActions as x, INotificationProgress as y, INotificationProgressProperties as z };
2692
+ export { AtLeastOne as A, IPromptOptions as B, CommandsRegistry as C, IStatusMessageOptions as D, NoOpNotification as E, FoldingRangeProvider as F, NoOpProgress as G, ILanguageFeaturesService as I, LanguageFeatureRegistry as L, NotificationsFilter as N, SubmenuAction as S, TextEdit as T, WorkspaceEdit as W, ILanguageConfigurationService as a, INotificationService as b, ILanguageIdCodec as c, IAction as d, ICommandService as e, ColorIdentifier as f, Color as g, LanguageSelector as h, Command as i, IInplaceReplaceSupportResult as j, WorkspaceEditMetadata as k, IActionRunner as l, IMarkerService as m, NotificationMessage as n, NotificationPriority as o, INotificationProperties as p, NeverShowAgainScope as q, registerColor as r, INeverShowAgainOptions as s, INotification as t, INotificationActions as u, INotificationProgress as v, INotificationProgressProperties as w, INotificationHandle as x, IPromptChoice as y, IPromptChoiceWithMenu as z };