@codingame/monaco-vscode-files-service-override 11.1.2 → 12.0.0
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.
- package/index.d.ts +230 -2
- package/index.js +860 -4
- package/package.json +31 -7
- package/vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.d.ts +68 -0
- package/vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.js +43 -44
- package/vscode/src/vs/platform/files/common/fileService.d.ts +113 -0
- package/vscode/src/vs/platform/files/common/fileService.js +157 -176
- package/vscode/src/vs/platform/files/common/io.d.ts +10 -0
- package/vscode/src/vs/platform/files/common/io.js +2 -1
- package/vscode/src/vs/workbench/services/files/browser/elevatedFileService.d.ts +9 -0
- package/vscode/src/vs/workbench/services/files/browser/elevatedFileService.js +2 -0
- package/vscode/src/vs/workbench/services/textfile/browser/browserTextFileService.d.ts +24 -0
- package/vscode/src/vs/workbench/services/textfile/browser/browserTextFileService.js +5 -2
- package/vscode/src/vs/workbench/services/textfile/browser/textFileService.d.ts +111 -0
- package/vscode/src/vs/workbench/services/textfile/browser/textFileService.js +55 -57
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.d.ts +76 -0
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.js +45 -45
- package/vscode/src/vs/workbench/services/textfile/common/textFileSaveParticipant.d.ts +15 -0
- package/vscode/src/vs/workbench/services/textfile/common/textFileSaveParticipant.js +13 -11
- package/files.js +0 -859
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { VSBuffer } from "vscode/vscode/vs/base/common/buffer";
|
|
2
|
+
import { CancellationToken } from "vscode/vscode/vs/base/common/cancellation";
|
|
3
|
+
import { IDataTransformer, IErrorTransformer, WriteableStream } from "vscode/vscode/vs/base/common/stream";
|
|
4
|
+
import { URI } from "vscode/vscode/vs/base/common/uri";
|
|
5
|
+
import { IFileReadStreamOptions, IFileSystemProviderWithOpenReadWriteCloseCapability } from "vscode/vscode/vs/platform/files/common/files";
|
|
6
|
+
export interface ICreateReadStreamOptions extends IFileReadStreamOptions {
|
|
7
|
+
readonly bufferSize: number;
|
|
8
|
+
readonly errorTransformer?: IErrorTransformer;
|
|
9
|
+
}
|
|
10
|
+
export declare function readFileIntoStream<T>(provider: IFileSystemProviderWithOpenReadWriteCloseCapability, resource: URI, target: WriteableStream<T>, transformer: IDataTransformer<VSBuffer, T>, options: ICreateReadStreamOptions, token: CancellationToken): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
|
|
2
3
|
import { canceled } from 'vscode/vscode/vs/base/common/errors';
|
|
3
4
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
@@ -69,7 +70,7 @@ function throwIfCancelled(token) {
|
|
|
69
70
|
}
|
|
70
71
|
function throwIfTooLarge(totalBytesRead, options) {
|
|
71
72
|
if (typeof options?.limits?.size === 'number' && totalBytesRead > options.limits.size) {
|
|
72
|
-
throw createFileSystemProviderError(localize(
|
|
73
|
+
throw createFileSystemProviderError(( localize(1779, "File is too large to open")), FileSystemProviderErrorCode.FileTooLarge);
|
|
73
74
|
}
|
|
74
75
|
return true;
|
|
75
76
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VSBuffer, VSBufferReadable, VSBufferReadableStream } from "vscode/vscode/vs/base/common/buffer";
|
|
2
|
+
import { URI } from "vscode/vscode/vs/base/common/uri";
|
|
3
|
+
import { IFileStatWithMetadata, IWriteFileOptions } from "vscode/vscode/vs/platform/files/common/files";
|
|
4
|
+
import { IElevatedFileService } from "vscode/vscode/vs/workbench/services/files/common/elevatedFileService.service";
|
|
5
|
+
export declare class BrowserElevatedFileService implements IElevatedFileService {
|
|
6
|
+
readonly _serviceBrand: undefined;
|
|
7
|
+
isSupported(resource: URI): boolean;
|
|
8
|
+
writeFileElevated(resource: URI, value: VSBuffer | VSBufferReadable | VSBufferReadableStream, options?: IWriteFileOptions): Promise<IFileStatWithMetadata>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AbstractTextFileService } from "./textFileService.js";
|
|
2
|
+
import { IWorkbenchEnvironmentService } from "vscode/vscode/vs/workbench/services/environment/common/environmentService.service";
|
|
3
|
+
import { ICodeEditorService } from "vscode/vscode/vs/editor/browser/services/codeEditorService";
|
|
4
|
+
import { IModelService } from "vscode/vscode/vs/editor/common/services/model";
|
|
5
|
+
import { ILanguageService } from "vscode/vscode/vs/editor/common/languages/language";
|
|
6
|
+
import { ITextResourceConfigurationService } from "vscode/vscode/vs/editor/common/services/textResourceConfiguration";
|
|
7
|
+
import { IFileDialogService } from "vscode/vscode/vs/platform/dialogs/common/dialogs.service";
|
|
8
|
+
import { IDialogService } from "vscode/vscode/vs/platform/dialogs/common/dialogs.service";
|
|
9
|
+
import { IFileService } from "vscode/vscode/vs/platform/files/common/files.service";
|
|
10
|
+
import { IInstantiationService } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
|
|
11
|
+
import { ILogService } from "vscode/vscode/vs/platform/log/common/log.service";
|
|
12
|
+
import { IElevatedFileService } from "vscode/vscode/vs/workbench/services/files/common/elevatedFileService.service";
|
|
13
|
+
import { IFilesConfigurationService } from "vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service";
|
|
14
|
+
import { ILifecycleService } from "vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service";
|
|
15
|
+
import { IPathService } from "vscode/vscode/vs/workbench/services/path/common/pathService.service";
|
|
16
|
+
import { IUntitledTextEditorService } from "vscode/vscode/vs/workbench/services/untitled/common/untitledTextEditorService.service";
|
|
17
|
+
import { IUriIdentityService } from "vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
|
|
18
|
+
import { IWorkingCopyFileService } from "vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service";
|
|
19
|
+
import { IDecorationsService } from "vscode/vscode/vs/workbench/services/decorations/common/decorations.service";
|
|
20
|
+
export declare class BrowserTextFileService extends AbstractTextFileService {
|
|
21
|
+
constructor(fileService: IFileService, untitledTextEditorService: IUntitledTextEditorService, lifecycleService: ILifecycleService, instantiationService: IInstantiationService, modelService: IModelService, environmentService: IWorkbenchEnvironmentService, dialogService: IDialogService, fileDialogService: IFileDialogService, textResourceConfigurationService: ITextResourceConfigurationService, filesConfigurationService: IFilesConfigurationService, codeEditorService: ICodeEditorService, pathService: IPathService, workingCopyFileService: IWorkingCopyFileService, uriIdentityService: IUriIdentityService, languageService: ILanguageService, elevatedFileService: IElevatedFileService, logService: ILogService, decorationsService: IDecorationsService);
|
|
22
|
+
private registerListeners;
|
|
23
|
+
private onBeforeShutdown;
|
|
24
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { AbstractTextFileService } from './textFileService.js';
|
|
4
|
+
import { TextFileEditorModelState } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
3
5
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
4
7
|
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
5
8
|
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
6
9
|
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
@@ -27,7 +30,7 @@ let BrowserTextFileService = class BrowserTextFileService extends AbstractTextFi
|
|
|
27
30
|
this._register(this.lifecycleService.onBeforeShutdown(event => event.veto(this.onBeforeShutdown(), 'veto.textFiles')));
|
|
28
31
|
}
|
|
29
32
|
onBeforeShutdown() {
|
|
30
|
-
if (( this.files.models.some(model => model.hasState(
|
|
33
|
+
if (( this.files.models.some(model => model.hasState(TextFileEditorModelState.PENDING_SAVE)))) {
|
|
31
34
|
return true;
|
|
32
35
|
}
|
|
33
36
|
return false;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { URI } from "vscode/vscode/vs/base/common/uri";
|
|
2
|
+
import { ITextFileStreamContent, ITextFileContent, IResourceEncodings, IReadTextFileOptions, IWriteTextFileOptions, ITextFileSaveOptions, ITextFileEditorModelManager, IResourceEncoding, ITextFileSaveAsOptions, IReadTextFileEncodingOptions } from "vscode/vscode/vs/workbench/services/textfile/common/textfiles";
|
|
3
|
+
import { ITextFileService } from "vscode/vscode/vs/workbench/services/textfile/common/textfiles.service";
|
|
4
|
+
import { IRevertOptions } from "vscode/vscode/vs/workbench/common/editor";
|
|
5
|
+
import { ILifecycleService } from "vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service";
|
|
6
|
+
import { IFileStatWithMetadata, ICreateFileOptions } from "vscode/vscode/vs/platform/files/common/files";
|
|
7
|
+
import { IFileService } from "vscode/vscode/vs/platform/files/common/files.service";
|
|
8
|
+
import { Disposable } from "vscode/vscode/vs/base/common/lifecycle";
|
|
9
|
+
import { IWorkbenchEnvironmentService } from "vscode/vscode/vs/workbench/services/environment/common/environmentService.service";
|
|
10
|
+
import { IUntitledTextEditorModelManager } from "@codingame/monaco-vscode-view-common-service-override/vscode/vs/workbench/services/untitled/common/untitledTextEditorService";
|
|
11
|
+
import { IUntitledTextEditorService } from "vscode/vscode/vs/workbench/services/untitled/common/untitledTextEditorService.service";
|
|
12
|
+
import { IInstantiationService } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
|
|
13
|
+
import { IModelService } from "vscode/vscode/vs/editor/common/services/model";
|
|
14
|
+
import { IFileDialogService } from "vscode/vscode/vs/platform/dialogs/common/dialogs.service";
|
|
15
|
+
import { IDialogService } from "vscode/vscode/vs/platform/dialogs/common/dialogs.service";
|
|
16
|
+
import { VSBuffer, VSBufferReadable, VSBufferReadableStream } from "vscode/vscode/vs/base/common/buffer";
|
|
17
|
+
import { ITextSnapshot } from "vscode/vscode/vs/editor/common/model";
|
|
18
|
+
import { ITextResourceConfigurationService } from "vscode/vscode/vs/editor/common/services/textResourceConfiguration";
|
|
19
|
+
import { IFilesConfigurationService } from "vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service";
|
|
20
|
+
import { ICodeEditorService } from "vscode/vscode/vs/editor/browser/services/codeEditorService";
|
|
21
|
+
import { IPathService } from "vscode/vscode/vs/workbench/services/path/common/pathService.service";
|
|
22
|
+
import { IFileOperationUndoRedoInfo } from "@codingame/monaco-vscode-base-service-override/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService";
|
|
23
|
+
import { IWorkingCopyFileService } from "vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service";
|
|
24
|
+
import { IUriIdentityService } from "vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
|
|
25
|
+
import { IWorkspaceContextService } from "vscode/vscode/vs/platform/workspace/common/workspace.service";
|
|
26
|
+
import { ReadableStream } from "vscode/vscode/vs/base/common/stream";
|
|
27
|
+
import { ILanguageService } from "vscode/vscode/vs/editor/common/languages/language";
|
|
28
|
+
import { ILogService } from "vscode/vscode/vs/platform/log/common/log.service";
|
|
29
|
+
import { IElevatedFileService } from "vscode/vscode/vs/workbench/services/files/common/elevatedFileService.service";
|
|
30
|
+
import { IDecorationsService } from "vscode/vscode/vs/workbench/services/decorations/common/decorations.service";
|
|
31
|
+
export declare abstract class AbstractTextFileService extends Disposable implements ITextFileService {
|
|
32
|
+
protected readonly fileService: IFileService;
|
|
33
|
+
private untitledTextEditorService;
|
|
34
|
+
protected readonly lifecycleService: ILifecycleService;
|
|
35
|
+
protected readonly instantiationService: IInstantiationService;
|
|
36
|
+
private readonly modelService;
|
|
37
|
+
protected readonly environmentService: IWorkbenchEnvironmentService;
|
|
38
|
+
private readonly dialogService;
|
|
39
|
+
private readonly fileDialogService;
|
|
40
|
+
protected readonly textResourceConfigurationService: ITextResourceConfigurationService;
|
|
41
|
+
protected readonly filesConfigurationService: IFilesConfigurationService;
|
|
42
|
+
private readonly codeEditorService;
|
|
43
|
+
private readonly pathService;
|
|
44
|
+
private readonly workingCopyFileService;
|
|
45
|
+
private readonly uriIdentityService;
|
|
46
|
+
private readonly languageService;
|
|
47
|
+
protected readonly logService: ILogService;
|
|
48
|
+
private readonly elevatedFileService;
|
|
49
|
+
private readonly decorationsService;
|
|
50
|
+
readonly _serviceBrand: undefined;
|
|
51
|
+
private static readonly TEXTFILE_SAVE_CREATE_SOURCE;
|
|
52
|
+
private static readonly TEXTFILE_SAVE_REPLACE_SOURCE;
|
|
53
|
+
readonly files: ITextFileEditorModelManager;
|
|
54
|
+
readonly untitled: IUntitledTextEditorModelManager;
|
|
55
|
+
constructor(fileService: IFileService, untitledTextEditorService: IUntitledTextEditorService, lifecycleService: ILifecycleService, instantiationService: IInstantiationService, modelService: IModelService, environmentService: IWorkbenchEnvironmentService, dialogService: IDialogService, fileDialogService: IFileDialogService, textResourceConfigurationService: ITextResourceConfigurationService, filesConfigurationService: IFilesConfigurationService, codeEditorService: ICodeEditorService, pathService: IPathService, workingCopyFileService: IWorkingCopyFileService, uriIdentityService: IUriIdentityService, languageService: ILanguageService, logService: ILogService, elevatedFileService: IElevatedFileService, decorationsService: IDecorationsService);
|
|
56
|
+
private provideDecorations;
|
|
57
|
+
private _encoding;
|
|
58
|
+
get encoding(): EncodingOracle;
|
|
59
|
+
read(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileContent>;
|
|
60
|
+
readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent>;
|
|
61
|
+
private doRead;
|
|
62
|
+
create(operations: {
|
|
63
|
+
resource: URI;
|
|
64
|
+
value?: string | ITextSnapshot;
|
|
65
|
+
options?: ICreateFileOptions;
|
|
66
|
+
}[], undoInfo?: IFileOperationUndoRedoInfo): Promise<readonly IFileStatWithMetadata[]>;
|
|
67
|
+
write(resource: URI, value: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise<IFileStatWithMetadata>;
|
|
68
|
+
getEncodedReadable(resource: URI, value: ITextSnapshot): Promise<VSBufferReadable>;
|
|
69
|
+
getEncodedReadable(resource: URI, value: string): Promise<VSBuffer>;
|
|
70
|
+
getEncodedReadable(resource: URI, value?: ITextSnapshot): Promise<VSBufferReadable | undefined>;
|
|
71
|
+
getEncodedReadable(resource: URI, value?: string): Promise<VSBuffer | undefined>;
|
|
72
|
+
getEncodedReadable(resource: URI, value?: string | ITextSnapshot): Promise<VSBuffer | VSBufferReadable | undefined>;
|
|
73
|
+
getEncodedReadable(resource: URI, value: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise<VSBuffer | VSBufferReadable>;
|
|
74
|
+
getDecodedStream(resource: URI, value: VSBufferReadableStream, options?: IReadTextFileEncodingOptions): Promise<ReadableStream<string>>;
|
|
75
|
+
private doGetDecodedStream;
|
|
76
|
+
save(resource: URI, options?: ITextFileSaveOptions): Promise<URI | undefined>;
|
|
77
|
+
saveAs(source: URI, target?: URI, options?: ITextFileSaveAsOptions): Promise<URI | undefined>;
|
|
78
|
+
private doSaveAs;
|
|
79
|
+
private doSaveAsTextFile;
|
|
80
|
+
private confirmOverwrite;
|
|
81
|
+
private confirmMakeWriteable;
|
|
82
|
+
private suggestSavePath;
|
|
83
|
+
suggestFilename(languageId: string, untitledName: string): string;
|
|
84
|
+
revert(resource: URI, options?: IRevertOptions): Promise<void>;
|
|
85
|
+
isDirty(resource: URI): boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface IEncodingOverride {
|
|
88
|
+
parent?: URI;
|
|
89
|
+
extension?: string;
|
|
90
|
+
encoding: string;
|
|
91
|
+
}
|
|
92
|
+
export declare class EncodingOracle extends Disposable implements IResourceEncodings {
|
|
93
|
+
private textResourceConfigurationService;
|
|
94
|
+
private environmentService;
|
|
95
|
+
private contextService;
|
|
96
|
+
private readonly uriIdentityService;
|
|
97
|
+
private _encodingOverrides;
|
|
98
|
+
protected get encodingOverrides(): IEncodingOverride[];
|
|
99
|
+
protected set encodingOverrides(value: IEncodingOverride[]);
|
|
100
|
+
constructor(textResourceConfigurationService: ITextResourceConfigurationService, environmentService: IWorkbenchEnvironmentService, contextService: IWorkspaceContextService, uriIdentityService: IUriIdentityService);
|
|
101
|
+
private registerListeners;
|
|
102
|
+
private getDefaultEncodingOverrides;
|
|
103
|
+
getWriteEncoding(resource: URI, options?: IWriteTextFileOptions): Promise<{
|
|
104
|
+
encoding: string;
|
|
105
|
+
addBOM: boolean;
|
|
106
|
+
}>;
|
|
107
|
+
getPreferredWriteEncoding(resource: URI, preferredEncoding?: string): Promise<IResourceEncoding>;
|
|
108
|
+
getPreferredReadEncoding(resource: URI, options?: IReadTextFileEncodingOptions, detectedEncoding?: string): Promise<IResourceEncoding>;
|
|
109
|
+
private getEncodingForResource;
|
|
110
|
+
private getEncodingOverride;
|
|
111
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
3
|
-
import { TextFileOperationError, toBufferOrReadable, stringToSnapshot } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
4
|
+
import { TextFileEditorModelState, TextFileOperationError, TextFileOperationResult, toBufferOrReadable, stringToSnapshot } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
4
5
|
import { SaveSourceRegistry } from 'vscode/vscode/vs/workbench/common/editor';
|
|
5
6
|
import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
7
|
+
import { FileOperationResult } from 'vscode/vscode/vs/platform/files/common/files';
|
|
6
8
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
7
9
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
10
|
import { extname } from 'vscode/vscode/vs/base/common/path';
|
|
9
11
|
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
10
12
|
import { IUntitledTextEditorService } from 'vscode/vscode/vs/workbench/services/untitled/common/untitledTextEditorService.service';
|
|
11
|
-
import { UntitledTextEditorModel } from 'vscode/vscode/vs/workbench/services/untitled/common/untitledTextEditorModel';
|
|
13
|
+
import { UntitledTextEditorModel } from '@codingame/monaco-vscode-0c06bfba-d24d-5c4d-90cd-b40cefb7f811-common/vscode/vs/workbench/services/untitled/common/untitledTextEditorModel';
|
|
12
14
|
import { TextFileEditorModelManager } from '../common/textFileEditorModelManager.js';
|
|
13
15
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
14
16
|
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
@@ -20,14 +22,14 @@ import { bufferToStream } from 'vscode/vscode/vs/base/common/buffer';
|
|
|
20
22
|
import { ITextResourceConfigurationService } from 'vscode/vscode/vs/editor/common/services/textResourceConfiguration';
|
|
21
23
|
import { PLAINTEXT_LANGUAGE_ID } from 'vscode/vscode/vs/editor/common/languages/modesRegistry';
|
|
22
24
|
import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service';
|
|
23
|
-
import { BaseTextEditorModel } from 'vscode/vscode/vs/workbench/common/editor/textEditorModel';
|
|
25
|
+
import { BaseTextEditorModel } from '@codingame/monaco-vscode-e571cbbb-526b-5d8b-92c5-a0437d2dabb3-common/vscode/vs/workbench/common/editor/textEditorModel';
|
|
24
26
|
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
25
27
|
import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService.service';
|
|
26
28
|
import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service';
|
|
27
29
|
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
28
30
|
import { WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
29
31
|
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
30
|
-
import { UTF8, toEncodeReadable, toDecodeStream, UTF16be, UTF16le, UTF8_with_bom, encodingExists } from 'vscode/vscode/vs/workbench/services/textfile/common/encoding';
|
|
32
|
+
import { UTF8, DecodeStreamErrorKind, toEncodeReadable, toDecodeStream, UTF16be, UTF16le, UTF8_with_bom, encodingExists } from '@codingame/monaco-vscode-2e67e044-0db9-5fa6-8bd1-3737a7d586d4-common/vscode/vs/workbench/services/textfile/common/encoding';
|
|
31
33
|
import { consumeStream } from 'vscode/vscode/vs/base/common/stream';
|
|
32
34
|
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
33
35
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
@@ -51,8 +53,8 @@ import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
|
|
|
51
53
|
var AbstractTextFileService_1;
|
|
52
54
|
let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
53
55
|
static { AbstractTextFileService_1 = this; }
|
|
54
|
-
static { this.TEXTFILE_SAVE_CREATE_SOURCE = SaveSourceRegistry.registerSource('textFileCreate.source', ( localize(
|
|
55
|
-
static { this.TEXTFILE_SAVE_REPLACE_SOURCE = SaveSourceRegistry.registerSource('textFileOverwrite.source', ( localize(
|
|
56
|
+
static { this.TEXTFILE_SAVE_CREATE_SOURCE = SaveSourceRegistry.registerSource('textFileCreate.source', ( localize(11758, "File Created"))); }
|
|
57
|
+
static { this.TEXTFILE_SAVE_REPLACE_SOURCE = SaveSourceRegistry.registerSource('textFileOverwrite.source', ( localize(11759, "File Replaced"))); }
|
|
56
58
|
constructor(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, codeEditorService, pathService, workingCopyFileService, uriIdentityService, languageService, logService, elevatedFileService, decorationsService) {
|
|
57
59
|
super();
|
|
58
60
|
this.fileService = fileService;
|
|
@@ -82,14 +84,14 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
82
84
|
constructor(files) {
|
|
83
85
|
super();
|
|
84
86
|
this.files = files;
|
|
85
|
-
this.label = ( localize(
|
|
86
|
-
this._onDidChange = this._register((
|
|
87
|
+
this.label = ( localize(11760, "Text File Model Decorations"));
|
|
88
|
+
this._onDidChange = this._register(( new Emitter()));
|
|
87
89
|
this.onDidChange = this._onDidChange.event;
|
|
88
90
|
this.registerListeners();
|
|
89
91
|
}
|
|
90
92
|
registerListeners() {
|
|
91
93
|
this._register(this.files.onDidResolve(({ model }) => {
|
|
92
|
-
if (model.isReadonly() || model.hasState(
|
|
94
|
+
if (model.isReadonly() || model.hasState(TextFileEditorModelState.ORPHAN)) {
|
|
93
95
|
this._onDidChange.fire([model.resource]);
|
|
94
96
|
}
|
|
95
97
|
}));
|
|
@@ -103,26 +105,26 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
103
105
|
return undefined;
|
|
104
106
|
}
|
|
105
107
|
const isReadonly = model.isReadonly();
|
|
106
|
-
const isOrphaned = model.hasState(
|
|
108
|
+
const isOrphaned = model.hasState(TextFileEditorModelState.ORPHAN);
|
|
107
109
|
if (isReadonly && isOrphaned) {
|
|
108
110
|
return {
|
|
109
111
|
color: listErrorForeground,
|
|
110
112
|
letter: Codicon.lockSmall,
|
|
111
113
|
strikethrough: true,
|
|
112
|
-
tooltip: ( localize(
|
|
114
|
+
tooltip: ( localize(11761, "Deleted, Read-only")),
|
|
113
115
|
};
|
|
114
116
|
}
|
|
115
117
|
else if (isReadonly) {
|
|
116
118
|
return {
|
|
117
119
|
letter: Codicon.lockSmall,
|
|
118
|
-
tooltip: ( localize(
|
|
120
|
+
tooltip: ( localize(11762, "Read-only")),
|
|
119
121
|
};
|
|
120
122
|
}
|
|
121
123
|
else if (isOrphaned) {
|
|
122
124
|
return {
|
|
123
125
|
color: listErrorForeground,
|
|
124
126
|
strikethrough: true,
|
|
125
|
-
tooltip: ( localize(
|
|
127
|
+
tooltip: ( localize(11763, "Deleted")),
|
|
126
128
|
};
|
|
127
129
|
}
|
|
128
130
|
return undefined;
|
|
@@ -156,7 +158,7 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
156
158
|
};
|
|
157
159
|
}
|
|
158
160
|
async doRead(resource, options) {
|
|
159
|
-
const cts = (
|
|
161
|
+
const cts = ( new CancellationTokenSource());
|
|
160
162
|
let bufferStream;
|
|
161
163
|
if (options?.preferUnbuffered) {
|
|
162
164
|
const content = await this.fileService.readFile(resource, options, cts.token);
|
|
@@ -174,12 +176,8 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
174
176
|
}
|
|
175
177
|
catch (error) {
|
|
176
178
|
cts.dispose(true);
|
|
177
|
-
if (error.decodeStreamErrorKind ===
|
|
178
|
-
throw (
|
|
179
|
-
localize(4480, "File seems to be binary and cannot be opened as text"),
|
|
180
|
-
0 ,
|
|
181
|
-
options
|
|
182
|
-
)));
|
|
179
|
+
if (error.decodeStreamErrorKind === DecodeStreamErrorKind.STREAM_IS_BINARY) {
|
|
180
|
+
throw ( new TextFileOperationError(( localize(11764, "File seems to be binary and cannot be opened as text")), TextFileOperationResult.FILE_IS_BINARY, options));
|
|
183
181
|
}
|
|
184
182
|
else {
|
|
185
183
|
throw error;
|
|
@@ -187,14 +185,14 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
187
185
|
}
|
|
188
186
|
}
|
|
189
187
|
async create(operations, undoInfo) {
|
|
190
|
-
const operationsWithContents = await Promise.all((
|
|
188
|
+
const operationsWithContents = await Promise.all(( operations.map(async (operation) => {
|
|
191
189
|
const contents = await this.getEncodedReadable(operation.resource, operation.value);
|
|
192
190
|
return {
|
|
193
191
|
resource: operation.resource,
|
|
194
192
|
contents,
|
|
195
193
|
overwrite: operation.options?.overwrite
|
|
196
194
|
};
|
|
197
|
-
})))
|
|
195
|
+
})));
|
|
198
196
|
return this.workingCopyFileService.create(operationsWithContents, CancellationToken.None, undoInfo);
|
|
199
197
|
}
|
|
200
198
|
async write(resource, value, options) {
|
|
@@ -332,8 +330,8 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
332
330
|
}
|
|
333
331
|
catch (error) {
|
|
334
332
|
if (targetExists) {
|
|
335
|
-
if (error.textFileOperationResult ===
|
|
336
|
-
error.fileOperationResult ===
|
|
333
|
+
if (error.textFileOperationResult === TextFileOperationResult.FILE_IS_BINARY ||
|
|
334
|
+
error.fileOperationResult === FileOperationResult.FILE_TOO_LARGE) {
|
|
337
335
|
await this.fileService.del(target);
|
|
338
336
|
return this.doSaveAsTextFile(sourceModel, source, target, options);
|
|
339
337
|
}
|
|
@@ -394,17 +392,17 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
394
392
|
const { confirmed } = await this.dialogService.confirm({
|
|
395
393
|
type: 'warning',
|
|
396
394
|
message: ( localize(
|
|
397
|
-
|
|
395
|
+
11765,
|
|
398
396
|
"'{0}' already exists. Do you want to replace it?",
|
|
399
397
|
basename(resource)
|
|
400
398
|
)),
|
|
401
399
|
detail: ( localize(
|
|
402
|
-
|
|
400
|
+
11766,
|
|
403
401
|
"A file or folder with the name '{0}' already exists in the folder '{1}'. Replacing it will overwrite its current contents.",
|
|
404
402
|
basename(resource),
|
|
405
403
|
basename(dirname(resource))
|
|
406
404
|
)),
|
|
407
|
-
primaryButton: ( localize(
|
|
405
|
+
primaryButton: ( localize(11767, "&&Replace")),
|
|
408
406
|
});
|
|
409
407
|
return confirmed;
|
|
410
408
|
}
|
|
@@ -412,12 +410,12 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
412
410
|
const { confirmed } = await this.dialogService.confirm({
|
|
413
411
|
type: 'warning',
|
|
414
412
|
message: ( localize(
|
|
415
|
-
|
|
413
|
+
11768,
|
|
416
414
|
"'{0}' is marked as read-only. Do you want to save anyway?",
|
|
417
415
|
basename(resource)
|
|
418
416
|
)),
|
|
419
|
-
detail: ( localize(
|
|
420
|
-
primaryButton: ( localize(
|
|
417
|
+
detail: ( localize(11769, "Paths can be configured as read-only via settings.")),
|
|
418
|
+
primaryButton: ( localize(11770, "&&Save Anyway"))
|
|
421
419
|
});
|
|
422
420
|
return confirmed;
|
|
423
421
|
}
|
|
@@ -500,26 +498,26 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
500
498
|
return false;
|
|
501
499
|
}
|
|
502
500
|
};
|
|
503
|
-
AbstractTextFileService = AbstractTextFileService_1 = (
|
|
504
|
-
(
|
|
505
|
-
(
|
|
506
|
-
(
|
|
507
|
-
(
|
|
508
|
-
(
|
|
509
|
-
(
|
|
510
|
-
(
|
|
511
|
-
(
|
|
512
|
-
(
|
|
513
|
-
(
|
|
514
|
-
(
|
|
515
|
-
(
|
|
516
|
-
(
|
|
517
|
-
(
|
|
518
|
-
(
|
|
519
|
-
(
|
|
520
|
-
(
|
|
521
|
-
(
|
|
522
|
-
], AbstractTextFileService))
|
|
501
|
+
AbstractTextFileService = AbstractTextFileService_1 = ( __decorate([
|
|
502
|
+
( __param(0, IFileService)),
|
|
503
|
+
( __param(1, IUntitledTextEditorService)),
|
|
504
|
+
( __param(2, ILifecycleService)),
|
|
505
|
+
( __param(3, IInstantiationService)),
|
|
506
|
+
( __param(4, IModelService)),
|
|
507
|
+
( __param(5, IWorkbenchEnvironmentService)),
|
|
508
|
+
( __param(6, IDialogService)),
|
|
509
|
+
( __param(7, IFileDialogService)),
|
|
510
|
+
( __param(8, ITextResourceConfigurationService)),
|
|
511
|
+
( __param(9, IFilesConfigurationService)),
|
|
512
|
+
( __param(10, ICodeEditorService)),
|
|
513
|
+
( __param(11, IPathService)),
|
|
514
|
+
( __param(12, IWorkingCopyFileService)),
|
|
515
|
+
( __param(13, IUriIdentityService)),
|
|
516
|
+
( __param(14, ILanguageService)),
|
|
517
|
+
( __param(15, ILogService)),
|
|
518
|
+
( __param(16, IElevatedFileService)),
|
|
519
|
+
( __param(17, IDecorationsService))
|
|
520
|
+
], AbstractTextFileService));
|
|
523
521
|
let EncodingOracle = class EncodingOracle extends Disposable {
|
|
524
522
|
get encodingOverrides() { return this._encodingOverrides; }
|
|
525
523
|
set encodingOverrides(value) { this._encodingOverrides = value; }
|
|
@@ -611,11 +609,11 @@ let EncodingOracle = class EncodingOracle extends Disposable {
|
|
|
611
609
|
return undefined;
|
|
612
610
|
}
|
|
613
611
|
};
|
|
614
|
-
EncodingOracle = (
|
|
615
|
-
(
|
|
616
|
-
(
|
|
617
|
-
(
|
|
618
|
-
(
|
|
619
|
-
], EncodingOracle))
|
|
612
|
+
EncodingOracle = ( __decorate([
|
|
613
|
+
( __param(0, ITextResourceConfigurationService)),
|
|
614
|
+
( __param(1, IWorkbenchEnvironmentService)),
|
|
615
|
+
( __param(2, IWorkspaceContextService)),
|
|
616
|
+
( __param(3, IUriIdentityService))
|
|
617
|
+
], EncodingOracle));
|
|
620
618
|
|
|
621
619
|
export { AbstractTextFileService, EncodingOracle };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Event } from "vscode/vscode/vs/base/common/event";
|
|
2
|
+
import { URI } from "vscode/vscode/vs/base/common/uri";
|
|
3
|
+
import { TextFileEditorModel } from "@codingame/monaco-vscode-0c06bfba-d24d-5c4d-90cd-b40cefb7f811-common/vscode/vs/workbench/services/textfile/common/textFileEditorModel";
|
|
4
|
+
import { IDisposable, Disposable } from "vscode/vscode/vs/base/common/lifecycle";
|
|
5
|
+
import { ITextFileEditorModel, ITextFileEditorModelManager, ITextFileEditorModelResolveOrCreateOptions, ITextFileResolveEvent, ITextFileSaveEvent, ITextFileSaveParticipant } from "vscode/vscode/vs/workbench/services/textfile/common/textfiles";
|
|
6
|
+
import { IInstantiationService } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
|
|
7
|
+
import { IFileService } from "vscode/vscode/vs/platform/files/common/files.service";
|
|
8
|
+
import { CancellationToken } from "vscode/vscode/vs/base/common/cancellation";
|
|
9
|
+
import { INotificationService } from "vscode/vscode/vs/platform/notification/common/notification.service";
|
|
10
|
+
import { IStoredFileWorkingCopySaveParticipantContext } from "@codingame/monaco-vscode-base-service-override/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService";
|
|
11
|
+
import { IWorkingCopyFileService } from "vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service";
|
|
12
|
+
import { IUriIdentityService } from "vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
|
|
13
|
+
import { IProgress, IProgressStep } from "vscode/vscode/vs/platform/progress/common/progress";
|
|
14
|
+
export declare class TextFileEditorModelManager extends Disposable implements ITextFileEditorModelManager {
|
|
15
|
+
private readonly instantiationService;
|
|
16
|
+
private readonly fileService;
|
|
17
|
+
private readonly notificationService;
|
|
18
|
+
private readonly workingCopyFileService;
|
|
19
|
+
private readonly uriIdentityService;
|
|
20
|
+
private readonly _onDidCreate;
|
|
21
|
+
readonly onDidCreate: Event<TextFileEditorModel>;
|
|
22
|
+
private readonly _onDidResolve;
|
|
23
|
+
readonly onDidResolve: Event<ITextFileResolveEvent>;
|
|
24
|
+
private readonly _onDidRemove;
|
|
25
|
+
readonly onDidRemove: Event<URI>;
|
|
26
|
+
private readonly _onDidChangeDirty;
|
|
27
|
+
readonly onDidChangeDirty: Event<TextFileEditorModel>;
|
|
28
|
+
private readonly _onDidChangeReadonly;
|
|
29
|
+
readonly onDidChangeReadonly: Event<TextFileEditorModel>;
|
|
30
|
+
private readonly _onDidChangeOrphaned;
|
|
31
|
+
readonly onDidChangeOrphaned: Event<TextFileEditorModel>;
|
|
32
|
+
private readonly _onDidSaveError;
|
|
33
|
+
readonly onDidSaveError: Event<TextFileEditorModel>;
|
|
34
|
+
private readonly _onDidSave;
|
|
35
|
+
readonly onDidSave: Event<ITextFileSaveEvent>;
|
|
36
|
+
private readonly _onDidRevert;
|
|
37
|
+
readonly onDidRevert: Event<TextFileEditorModel>;
|
|
38
|
+
private readonly _onDidChangeEncoding;
|
|
39
|
+
readonly onDidChangeEncoding: Event<TextFileEditorModel>;
|
|
40
|
+
private readonly mapResourceToModel;
|
|
41
|
+
private readonly mapResourceToModelListeners;
|
|
42
|
+
private readonly mapResourceToDisposeListener;
|
|
43
|
+
private readonly mapResourceToPendingModelResolvers;
|
|
44
|
+
private readonly modelResolveQueue;
|
|
45
|
+
saveErrorHandler: {
|
|
46
|
+
onSaveError(error: Error, model: ITextFileEditorModel): void;
|
|
47
|
+
};
|
|
48
|
+
get models(): TextFileEditorModel[];
|
|
49
|
+
constructor(instantiationService: IInstantiationService, fileService: IFileService, notificationService: INotificationService, workingCopyFileService: IWorkingCopyFileService, uriIdentityService: IUriIdentityService);
|
|
50
|
+
private registerListeners;
|
|
51
|
+
private onDidFilesChange;
|
|
52
|
+
private onDidChangeFileSystemProviderCapabilities;
|
|
53
|
+
private onDidChangeFileSystemProviderRegistrations;
|
|
54
|
+
private queueModelReloads;
|
|
55
|
+
private queueModelReload;
|
|
56
|
+
private readonly mapCorrelationIdToModelsToRestore;
|
|
57
|
+
private onWillRunWorkingCopyFileOperation;
|
|
58
|
+
private onDidFailWorkingCopyFileOperation;
|
|
59
|
+
private onDidRunWorkingCopyFileOperation;
|
|
60
|
+
get(resource: URI): TextFileEditorModel | undefined;
|
|
61
|
+
private has;
|
|
62
|
+
private reload;
|
|
63
|
+
resolve(resource: URI, options?: ITextFileEditorModelResolveOrCreateOptions): Promise<TextFileEditorModel>;
|
|
64
|
+
private doResolve;
|
|
65
|
+
private joinPendingResolves;
|
|
66
|
+
private doJoinPendingResolves;
|
|
67
|
+
private registerModel;
|
|
68
|
+
add(resource: URI, model: TextFileEditorModel): void;
|
|
69
|
+
remove(resource: URI): void;
|
|
70
|
+
private readonly saveParticipants;
|
|
71
|
+
addSaveParticipant(participant: ITextFileSaveParticipant): IDisposable;
|
|
72
|
+
runSaveParticipants(model: ITextFileEditorModel, context: IStoredFileWorkingCopySaveParticipantContext, progress: IProgress<IProgressStep>, token: CancellationToken): Promise<void>;
|
|
73
|
+
canDispose(model: TextFileEditorModel): true | Promise<true>;
|
|
74
|
+
private doCanDispose;
|
|
75
|
+
dispose(): void;
|
|
76
|
+
}
|