@codingame/monaco-vscode-files-service-override 25.1.2 → 26.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/package.json +2 -2
- package/vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.js +129 -80
- package/vscode/src/vs/platform/files/common/fileService.js +398 -218
- package/vscode/src/vs/platform/files/common/io.js +30 -20
- package/vscode/src/vs/workbench/services/files/browser/elevatedFileService.js +1 -1
- package/vscode/src/vs/workbench/services/textfile/browser/browserTextFileService.js +44 -23
- package/vscode/src/vs/workbench/services/textfile/browser/textFileService.js +176 -116
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.js +95 -71
- package/vscode/src/vs/workbench/services/textfile/common/textFileSaveParticipant.js +6 -11
|
@@ -8,15 +8,13 @@ async function readFileIntoStream(provider, resource, target, transformer, optio
|
|
|
8
8
|
let error = undefined;
|
|
9
9
|
try {
|
|
10
10
|
await doReadFileIntoStream(provider, resource, target, transformer, options, token);
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
11
|
+
} catch (err) {
|
|
13
12
|
error = err;
|
|
14
|
-
}
|
|
15
|
-
finally {
|
|
13
|
+
} finally {
|
|
16
14
|
if (error && options.errorTransformer) {
|
|
17
15
|
error = options.errorTransformer(error);
|
|
18
16
|
}
|
|
19
|
-
if (typeof error !==
|
|
17
|
+
if (typeof error !== "undefined") {
|
|
20
18
|
target.error(error);
|
|
21
19
|
}
|
|
22
20
|
target.end();
|
|
@@ -24,41 +22,53 @@ async function readFileIntoStream(provider, resource, target, transformer, optio
|
|
|
24
22
|
}
|
|
25
23
|
async function doReadFileIntoStream(provider, resource, target, transformer, options, token) {
|
|
26
24
|
throwIfCancelled(token);
|
|
27
|
-
const handle = await provider.open(resource, {
|
|
25
|
+
const handle = await provider.open(resource, {
|
|
26
|
+
create: false
|
|
27
|
+
});
|
|
28
28
|
try {
|
|
29
29
|
throwIfCancelled(token);
|
|
30
30
|
let totalBytesRead = 0;
|
|
31
31
|
let bytesRead = 0;
|
|
32
|
-
let allowedRemainingBytes = (options && typeof options.length ===
|
|
33
|
-
let buffer = VSBuffer.alloc(Math.min(
|
|
34
|
-
|
|
32
|
+
let allowedRemainingBytes = (options && typeof options.length === "number") ? options.length : undefined;
|
|
33
|
+
let buffer = VSBuffer.alloc(Math.min(
|
|
34
|
+
options.bufferSize,
|
|
35
|
+
typeof allowedRemainingBytes === "number" ? allowedRemainingBytes : options.bufferSize
|
|
36
|
+
));
|
|
37
|
+
let posInFile = options && typeof options.position === "number" ? options.position : 0;
|
|
35
38
|
let posInBuffer = 0;
|
|
36
39
|
do {
|
|
37
|
-
bytesRead = await provider.read(
|
|
40
|
+
bytesRead = await provider.read(
|
|
41
|
+
handle,
|
|
42
|
+
posInFile,
|
|
43
|
+
buffer.buffer,
|
|
44
|
+
posInBuffer,
|
|
45
|
+
buffer.byteLength - posInBuffer
|
|
46
|
+
);
|
|
38
47
|
posInFile += bytesRead;
|
|
39
48
|
posInBuffer += bytesRead;
|
|
40
49
|
totalBytesRead += bytesRead;
|
|
41
|
-
if (typeof allowedRemainingBytes ===
|
|
50
|
+
if (typeof allowedRemainingBytes === "number") {
|
|
42
51
|
allowedRemainingBytes -= bytesRead;
|
|
43
52
|
}
|
|
44
53
|
if (posInBuffer === buffer.byteLength) {
|
|
45
54
|
await target.write(transformer(buffer));
|
|
46
|
-
buffer = VSBuffer.alloc(Math.min(
|
|
55
|
+
buffer = VSBuffer.alloc(Math.min(
|
|
56
|
+
options.bufferSize,
|
|
57
|
+
typeof allowedRemainingBytes === "number" ? allowedRemainingBytes : options.bufferSize
|
|
58
|
+
));
|
|
47
59
|
posInBuffer = 0;
|
|
48
60
|
}
|
|
49
|
-
} while (bytesRead > 0 && (typeof allowedRemainingBytes !==
|
|
61
|
+
} while (bytesRead > 0 && (typeof allowedRemainingBytes !== "number" || allowedRemainingBytes > 0) && throwIfCancelled(token) && throwIfTooLarge(totalBytesRead, options));
|
|
50
62
|
if (posInBuffer > 0) {
|
|
51
63
|
let lastChunkLength = posInBuffer;
|
|
52
|
-
if (typeof allowedRemainingBytes ===
|
|
64
|
+
if (typeof allowedRemainingBytes === "number") {
|
|
53
65
|
lastChunkLength = Math.min(posInBuffer, allowedRemainingBytes);
|
|
54
66
|
}
|
|
55
67
|
target.write(transformer(buffer.slice(0, lastChunkLength)));
|
|
56
68
|
}
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
69
|
+
} catch (error) {
|
|
59
70
|
throw ensureFileSystemProviderError(error);
|
|
60
|
-
}
|
|
61
|
-
finally {
|
|
71
|
+
} finally {
|
|
62
72
|
await provider.close(handle);
|
|
63
73
|
}
|
|
64
74
|
}
|
|
@@ -69,8 +79,8 @@ function throwIfCancelled(token) {
|
|
|
69
79
|
return true;
|
|
70
80
|
}
|
|
71
81
|
function throwIfTooLarge(totalBytesRead, options) {
|
|
72
|
-
if (typeof options?.limits?.size ===
|
|
73
|
-
throw createFileSystemProviderError(( localize(
|
|
82
|
+
if (typeof options?.limits?.size === "number" && totalBytesRead > options.limits.size) {
|
|
83
|
+
throw createFileSystemProviderError(( localize(1946, "File is too large to open")), FileSystemProviderErrorCode.FileTooLarge);
|
|
74
84
|
}
|
|
75
85
|
return true;
|
|
76
86
|
}
|
|
@@ -22,12 +22,52 @@ import { IWorkingCopyFileService } from '@codingame/monaco-vscode-api/vscode/vs/
|
|
|
22
22
|
import { IDecorationsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/decorations/common/decorations.service';
|
|
23
23
|
|
|
24
24
|
let BrowserTextFileService = class BrowserTextFileService extends AbstractTextFileService {
|
|
25
|
-
constructor(
|
|
26
|
-
|
|
25
|
+
constructor(
|
|
26
|
+
fileService,
|
|
27
|
+
untitledTextEditorService,
|
|
28
|
+
lifecycleService,
|
|
29
|
+
instantiationService,
|
|
30
|
+
modelService,
|
|
31
|
+
environmentService,
|
|
32
|
+
dialogService,
|
|
33
|
+
fileDialogService,
|
|
34
|
+
textResourceConfigurationService,
|
|
35
|
+
filesConfigurationService,
|
|
36
|
+
codeEditorService,
|
|
37
|
+
pathService,
|
|
38
|
+
workingCopyFileService,
|
|
39
|
+
uriIdentityService,
|
|
40
|
+
languageService,
|
|
41
|
+
elevatedFileService,
|
|
42
|
+
logService,
|
|
43
|
+
decorationsService
|
|
44
|
+
) {
|
|
45
|
+
super(
|
|
46
|
+
fileService,
|
|
47
|
+
untitledTextEditorService,
|
|
48
|
+
lifecycleService,
|
|
49
|
+
instantiationService,
|
|
50
|
+
modelService,
|
|
51
|
+
environmentService,
|
|
52
|
+
dialogService,
|
|
53
|
+
fileDialogService,
|
|
54
|
+
textResourceConfigurationService,
|
|
55
|
+
filesConfigurationService,
|
|
56
|
+
codeEditorService,
|
|
57
|
+
pathService,
|
|
58
|
+
workingCopyFileService,
|
|
59
|
+
uriIdentityService,
|
|
60
|
+
languageService,
|
|
61
|
+
logService,
|
|
62
|
+
elevatedFileService,
|
|
63
|
+
decorationsService
|
|
64
|
+
);
|
|
27
65
|
this.registerListeners();
|
|
28
66
|
}
|
|
29
67
|
registerListeners() {
|
|
30
|
-
this._register(
|
|
68
|
+
this._register(
|
|
69
|
+
this.lifecycleService.onBeforeShutdown(event => event.veto(this.onBeforeShutdown(), "veto.textFiles"))
|
|
70
|
+
);
|
|
31
71
|
}
|
|
32
72
|
onBeforeShutdown() {
|
|
33
73
|
if (( this.files.models.some(model => model.hasState(TextFileEditorModelState.PENDING_SAVE)))) {
|
|
@@ -36,25 +76,6 @@ let BrowserTextFileService = class BrowserTextFileService extends AbstractTextFi
|
|
|
36
76
|
return false;
|
|
37
77
|
}
|
|
38
78
|
};
|
|
39
|
-
BrowserTextFileService = ( __decorate([
|
|
40
|
-
( __param(0, IFileService)),
|
|
41
|
-
( __param(1, IUntitledTextEditorService)),
|
|
42
|
-
( __param(2, ILifecycleService)),
|
|
43
|
-
( __param(3, IInstantiationService)),
|
|
44
|
-
( __param(4, IModelService)),
|
|
45
|
-
( __param(5, IWorkbenchEnvironmentService)),
|
|
46
|
-
( __param(6, IDialogService)),
|
|
47
|
-
( __param(7, IFileDialogService)),
|
|
48
|
-
( __param(8, ITextResourceConfigurationService)),
|
|
49
|
-
( __param(9, IFilesConfigurationService)),
|
|
50
|
-
( __param(10, ICodeEditorService)),
|
|
51
|
-
( __param(11, IPathService)),
|
|
52
|
-
( __param(12, IWorkingCopyFileService)),
|
|
53
|
-
( __param(13, IUriIdentityService)),
|
|
54
|
-
( __param(14, ILanguageService)),
|
|
55
|
-
( __param(15, IElevatedFileService)),
|
|
56
|
-
( __param(16, ILogService)),
|
|
57
|
-
( __param(17, IDecorationsService))
|
|
58
|
-
], BrowserTextFileService));
|
|
79
|
+
BrowserTextFileService = ( __decorate([( __param(0, IFileService)), ( __param(1, IUntitledTextEditorService)), ( __param(2, ILifecycleService)), ( __param(3, IInstantiationService)), ( __param(4, IModelService)), ( __param(5, IWorkbenchEnvironmentService)), ( __param(6, IDialogService)), ( __param(7, IFileDialogService)), ( __param(8, ITextResourceConfigurationService)), ( __param(9, IFilesConfigurationService)), ( __param(10, ICodeEditorService)), ( __param(11, IPathService)), ( __param(12, IWorkingCopyFileService)), ( __param(13, IUriIdentityService)), ( __param(14, ILanguageService)), ( __param(15, IElevatedFileService)), ( __param(16, ILogService)), ( __param(17, IDecorationsService))], BrowserTextFileService));
|
|
59
80
|
|
|
60
81
|
export { BrowserTextFileService };
|