@codingame/monaco-vscode-api 1.76.9 → 1.78.0-next.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/README.md +87 -49
- package/dist/Bibtex.tmLanguage.js +2 -0
- package/dist/Handlebars.tmLanguage.js +2 -0
- package/dist/JSON.tmLanguage.js +2 -0
- package/dist/JSONC.tmLanguage.js +2 -0
- package/dist/JavaScript.tmLanguage.js +2 -0
- package/dist/JavaScriptReact.tmLanguage.js +2 -0
- package/dist/LaTeX.tmLanguage.js +2 -0
- package/dist/MagicPython.tmLanguage.js +2 -0
- package/dist/MagicRegExp.tmLanguage.js +2 -0
- package/dist/Red-color-theme.js +2 -0
- package/dist/Regular Expressions (JavaScript).js +2 -0
- package/dist/TeX.tmLanguage.js +2 -0
- package/dist/TypeScript.tmLanguage.js +2 -0
- package/dist/TypeScriptReact.tmLanguage.js +2 -0
- package/dist/_.contribution.js +1 -1
- package/dist/abyss-color-theme.js +2 -0
- package/dist/api.js +1 -3
- package/dist/api2.js +421 -18091
- package/dist/asp-vb-net.tmlanguage.js +2 -0
- package/dist/assets/diffLineDeleted.mp3 +0 -0
- package/dist/assets/diffLineInserted.mp3 +0 -0
- package/dist/assets/diffLineModified.mp3 +0 -0
- package/dist/audioCue.js +108 -478
- package/dist/bat.js +9 -0
- package/dist/batchfile.js +2 -0
- package/dist/batchfile.tmLanguage.js +2 -0
- package/dist/button.js +35 -8
- package/dist/c.js +2 -0
- package/dist/c.tmLanguage.js +2 -0
- package/dist/clojure.js +8 -0
- package/dist/clojure.tmLanguage.js +2 -0
- package/dist/coffeescript.js +9 -0
- package/dist/coffeescript.tmLanguage.js +2 -0
- package/dist/coffeescript2.js +2 -0
- package/dist/configuration.d.ts +269 -4
- package/dist/configuration.js +4326 -328
- package/dist/configuration2.js +14 -324
- package/dist/cpp-grammar-bailout.tmLanguage.js +2 -0
- package/dist/cpp.embedded.macro.tmLanguage.js +2 -0
- package/dist/cpp.js +16 -0
- package/dist/cpp.tmLanguage.js +2 -0
- package/dist/cpp2.js +2 -0
- package/dist/csharp.js +9 -0
- package/dist/csharp.tmLanguage.js +2 -0
- package/dist/csharp2.js +2 -0
- package/dist/cshtml.tmLanguage.js +2 -0
- package/dist/css.js +8 -0
- package/dist/css.tmLanguage.js +2 -0
- package/dist/cuda-cpp.tmLanguage.js +2 -0
- package/dist/dark_plus.js +2 -0
- package/dist/dark_plus_experimental.js +2 -0
- package/dist/dark_vs.js +2 -0
- package/dist/dart.js +8 -0
- package/dist/dart.tmLanguage.js +2 -0
- package/dist/debug.js +12115 -12209
- package/dist/default-extensions/bat.js +12 -0
- package/dist/default-extensions/clojure.js +11 -0
- package/dist/default-extensions/coffeescript.js +12 -0
- package/dist/default-extensions/cpp.js +19 -0
- package/dist/default-extensions/csharp.js +12 -0
- package/dist/default-extensions/css.js +11 -0
- package/dist/default-extensions/dart.js +11 -0
- package/dist/default-extensions/diff.js +11 -0
- package/dist/default-extensions/docker.js +11 -0
- package/dist/default-extensions/fsharp.js +12 -0
- package/dist/default-extensions/go.js +11 -0
- package/dist/default-extensions/groovy.js +12 -0
- package/dist/default-extensions/handlebars.js +11 -0
- package/dist/default-extensions/hlsl.js +11 -0
- package/dist/default-extensions/html.js +13 -0
- package/dist/default-extensions/ini.js +13 -0
- package/dist/default-extensions/java.js +12 -0
- package/dist/default-extensions/javascript.js +17 -0
- package/dist/default-extensions/json.js +13 -0
- package/dist/default-extensions/julia.js +11 -0
- package/dist/default-extensions/latex.js +14 -0
- package/dist/default-extensions/less.js +11 -0
- package/dist/default-extensions/log.js +10 -0
- package/dist/default-extensions/lua.js +11 -0
- package/dist/default-extensions/make.js +11 -0
- package/dist/default-extensions/markdown-basics.js +12 -0
- package/dist/default-extensions/objective-c.js +13 -0
- package/dist/default-extensions/perl.js +13 -0
- package/dist/default-extensions/php.js +13 -0
- package/dist/default-extensions/powershell.js +11 -0
- package/dist/default-extensions/pug.js +11 -0
- package/dist/default-extensions/python.js +12 -0
- package/dist/default-extensions/r.js +11 -0
- package/dist/default-extensions/razor.js +11 -0
- package/dist/default-extensions/ruby.js +11 -0
- package/dist/default-extensions/rust.js +11 -0
- package/dist/default-extensions/scss.js +12 -0
- package/dist/default-extensions/shaderlab.js +11 -0
- package/dist/default-extensions/shellscript.js +11 -0
- package/dist/default-extensions/sql.js +11 -0
- package/dist/default-extensions/swift.js +12 -0
- package/dist/default-extensions/theme-abyss.js +10 -0
- package/dist/default-extensions/theme-defaults.js +18 -0
- package/dist/default-extensions/theme-kimbie-dark.js +10 -0
- package/dist/default-extensions/theme-monokai-dimmed.js +10 -0
- package/dist/default-extensions/theme-monokai.js +10 -0
- package/dist/default-extensions/theme-quietlight.js +10 -0
- package/dist/default-extensions/theme-red.js +10 -0
- package/dist/default-extensions/theme-seti.js +10 -0
- package/dist/default-extensions/theme-solarized-dark.js +10 -0
- package/dist/default-extensions/theme-solarized-light.js +10 -0
- package/dist/default-extensions/theme-tomorrow-night-blue.js +10 -0
- package/dist/default-extensions/typescript-basics.js +17 -0
- package/dist/default-extensions/vb.js +12 -0
- package/dist/default-extensions/xml.js +13 -0
- package/dist/default-extensions/yaml.js +13 -0
- package/dist/dialogs.js +12 -216
- package/dist/diff.js +8 -0
- package/dist/diff.tmLanguage.js +2 -0
- package/dist/dimmed-monokai-color-theme.js +2 -0
- package/dist/docker.js +8 -0
- package/dist/docker.tmLanguage.js +2 -0
- package/dist/dom.js +101 -0
- package/dist/extensionManagement.js +4 -0
- package/dist/extensions.d.ts +368 -23
- package/dist/extensions.js +4 -85
- package/dist/extensionsRegistry.js +63 -64
- package/dist/files.d.ts +845 -0
- package/dist/files.js +1805 -1151
- package/dist/files2.js +32 -0
- package/dist/fsharp.js +9 -0
- package/dist/fsharp.tmLanguage.js +2 -0
- package/dist/fsharp2.js +2 -0
- package/dist/go.js +8 -0
- package/dist/go.tmLanguage.js +2 -0
- package/dist/groovy.js +9 -0
- package/dist/groovy.tmLanguage.js +2 -0
- package/dist/groovy2.js +2 -0
- package/dist/handlebars.js +8 -0
- package/dist/hc_black.js +2 -0
- package/dist/hc_light.js +2 -0
- package/dist/hlsl.js +8 -0
- package/dist/hlsl.tmLanguage.js +2 -0
- package/dist/html-derivative.tmLanguage.js +2 -0
- package/dist/html.js +10 -0
- package/dist/html.tmLanguage.js +2 -0
- package/dist/html.tmLanguage2.js +2 -0
- package/dist/html2.js +2 -0
- package/dist/ini.js +10 -0
- package/dist/ini.language-configuration.js +2 -0
- package/dist/ini.tmLanguage.js +2 -0
- package/dist/injection.js +1 -1
- package/dist/java.js +9 -0
- package/dist/java.tmLanguage.js +2 -0
- package/dist/java2.js +2 -0
- package/dist/javascript-language-configuration.js +2 -0
- package/dist/javascript.js +14 -0
- package/dist/javascript2.js +2 -0
- package/dist/jsdoc.js.injection.tmLanguage.js +2 -0
- package/dist/jsdoc.ts.injection.tmLanguage.js +2 -0
- package/dist/json.js +10 -0
- package/dist/jsonErrorMessages.js +1 -1
- package/dist/julia.js +8 -0
- package/dist/julia.tmLanguage.js +2 -0
- package/dist/keybindings.d.ts +1 -10
- package/dist/keybindings.js +291 -353
- package/dist/kimbie-dark-color-theme.js +2 -0
- package/dist/language-configuration.js +2 -0
- package/dist/language-configuration10.js +2 -0
- package/dist/language-configuration11.js +2 -0
- package/dist/language-configuration12.js +2 -0
- package/dist/language-configuration13.js +2 -0
- package/dist/language-configuration14.js +2 -0
- package/dist/language-configuration15.js +2 -0
- package/dist/language-configuration16.js +2 -0
- package/dist/language-configuration17.js +2 -0
- package/dist/language-configuration18.js +2 -0
- package/dist/language-configuration19.js +2 -0
- package/dist/language-configuration2.js +2 -0
- package/dist/language-configuration20.js +2 -0
- package/dist/language-configuration21.js +2 -0
- package/dist/language-configuration22.js +2 -0
- package/dist/language-configuration23.js +2 -0
- package/dist/language-configuration24.js +2 -0
- package/dist/language-configuration25.js +2 -0
- package/dist/language-configuration26.js +2 -0
- package/dist/language-configuration27.js +2 -0
- package/dist/language-configuration28.js +2 -0
- package/dist/language-configuration29.js +2 -0
- package/dist/language-configuration3.js +2 -0
- package/dist/language-configuration30.js +2 -0
- package/dist/language-configuration31.js +2 -0
- package/dist/language-configuration32.js +2 -0
- package/dist/language-configuration33.js +2 -0
- package/dist/language-configuration34.js +2 -0
- package/dist/language-configuration35.js +2 -0
- package/dist/language-configuration36.js +2 -0
- package/dist/language-configuration37.js +2 -0
- package/dist/language-configuration38.js +2 -0
- package/dist/language-configuration39.js +2 -0
- package/dist/language-configuration4.js +2 -0
- package/dist/language-configuration5.js +2 -0
- package/dist/language-configuration6.js +2 -0
- package/dist/language-configuration7.js +2 -0
- package/dist/language-configuration8.js +2 -0
- package/dist/language-configuration9.js +2 -0
- package/dist/languageService.js +5 -6
- package/dist/languages.d.ts +66 -1
- package/dist/languages.js +924 -5
- package/dist/latex.js +11 -0
- package/dist/layout.contribution.darwin.js +1 -1
- package/dist/layout.contribution.linux.js +1 -1
- package/dist/layout.contribution.win.js +1 -1
- package/dist/layout.js +4 -10
- package/dist/layoutService.js +10 -2
- package/dist/less.js +8 -0
- package/dist/less.tmLanguage.js +2 -0
- package/dist/light_plus.js +2 -0
- package/dist/light_plus_experimental.js +2 -0
- package/dist/light_vs.js +2 -0
- package/dist/log.js +7 -0
- package/dist/log.tmLanguage.js +2 -0
- package/dist/lua.js +8 -0
- package/dist/lua.tmLanguage.js +2 -0
- package/dist/make.js +8 -0
- package/dist/make.tmLanguage.js +2 -0
- package/dist/markdown-basics.js +9 -0
- package/dist/markdown-latex-combined.tmLanguage.js +2 -0
- package/dist/markdown.js +2 -0
- package/dist/markdown.tmLanguage.js +2 -0
- package/dist/memento.js +91 -0
- package/dist/modelEditor.d.ts +1480 -138
- package/dist/modelEditor.js +8700 -326
- package/dist/monaco.d.ts +987 -15
- package/dist/monaco.js +40 -10
- package/dist/monokai-color-theme.js +2 -0
- package/dist/notifications.js +86 -64
- package/dist/objective-c.js +10 -0
- package/dist/objective-c.tmLanguage.js +2 -0
- package/dist/objective-c__.tmLanguage.js +2 -0
- package/dist/perl.js +10 -0
- package/dist/perl.language-configuration.js +2 -0
- package/dist/perl.tmLanguage.js +2 -0
- package/dist/perl6.language-configuration.js +2 -0
- package/dist/perl6.tmLanguage.js +2 -0
- package/dist/php.js +10 -0
- package/dist/php.tmLanguage.js +2 -0
- package/dist/php2.js +2 -0
- package/dist/platform.js +105 -0
- package/dist/platform.tmLanguage.js +2 -0
- package/dist/polyfill.js +51923 -11069
- package/dist/powershell.js +8 -0
- package/dist/powershell.tmLanguage.js +2 -0
- package/dist/preferences.js +2532 -0
- package/dist/properties.language-configuration.js +2 -0
- package/dist/pug.js +8 -0
- package/dist/pug.tmLanguage.js +2 -0
- package/dist/python.js +9 -0
- package/dist/quietlight-color-theme.js +2 -0
- package/dist/r.js +8 -0
- package/dist/r.tmLanguage.js +2 -0
- package/dist/razor.js +8 -0
- package/dist/rollup-vsix-plugin.d.ts +8 -0
- package/dist/rollup-vsix-plugin.js +104 -0
- package/dist/ruby.js +8 -0
- package/dist/ruby.tmLanguage.js +2 -0
- package/dist/rust.js +8 -0
- package/dist/rust.tmLanguage.js +2 -0
- package/dist/sassdoc.tmLanguage.js +2 -0
- package/dist/scss.js +9 -0
- package/dist/scss.tmLanguage.js +2 -0
- package/dist/services.d.ts +12988 -12840
- package/dist/services.js +1 -1
- package/dist/shaderlab.js +8 -0
- package/dist/shaderlab.tmLanguage.js +2 -0
- package/dist/shell-unix-bash.tmLanguage.js +2 -0
- package/dist/shellscript.js +8 -0
- package/dist/snippets.js +6 -11
- package/dist/snippetsService.js +7 -10
- package/dist/solarized-dark-color-theme.js +2 -0
- package/dist/solarized-light-color-theme.js +2 -0
- package/dist/sql.js +8 -0
- package/dist/sql.tmLanguage.js +2 -0
- package/dist/swift.js +9 -0
- package/dist/swift.tmLanguage.js +2 -0
- package/dist/swift2.js +2 -0
- package/dist/tags-language-configuration.js +2 -0
- package/dist/textmate.d.ts +0 -264
- package/dist/textmate.js +402 -66
- package/dist/theme-abyss.js +7 -0
- package/dist/theme-defaults.js +15 -0
- package/dist/theme-kimbie-dark.js +7 -0
- package/dist/theme-monokai-dimmed.js +7 -0
- package/dist/theme-monokai.js +7 -0
- package/dist/theme-quietlight.js +7 -0
- package/dist/theme-red.js +7 -0
- package/dist/theme-seti.js +7 -0
- package/dist/theme-solarized-dark.js +7 -0
- package/dist/theme-solarized-light.js +7 -0
- package/dist/theme-tomorrow-night-blue.js +7 -0
- package/dist/theme.js +6 -11
- package/dist/{contextkeys.js → theme2.js} +165 -143
- package/dist/tokenClassificationRegistry.js +46 -2
- package/dist/tomorrow-night-blue-color-theme.js +2 -0
- package/dist/typescript-basics.js +14 -0
- package/dist/typescript.js +2 -0
- package/dist/unboundCommands.js +41 -0
- package/dist/utils.js +345 -0
- package/dist/vb.js +9 -0
- package/dist/vb2.js +2 -0
- package/dist/vs-seti-icon-theme.js +2 -0
- package/dist/vs_minimal-icon-theme.js +2 -0
- package/dist/xml.js +10 -0
- package/dist/xml.language-configuration.js +2 -0
- package/dist/xml.tmLanguage.js +2 -0
- package/dist/xsl.language-configuration.js +2 -0
- package/dist/xsl.tmLanguage.js +2 -0
- package/dist/yaml.js +10 -0
- package/dist/yaml.tmLanguage.js +2 -0
- package/package.json +50 -33
- package/dist/async.js +0 -301
- package/dist/cancellation.js +0 -3
- package/dist/configurationRegistry.js +0 -441
- package/dist/extensionResourceLoader.js +0 -96
- package/dist/labels.js +0 -14
- package/dist/languageConfiguration.js +0 -919
- package/dist/missing-services.js +0 -5554
- package/dist/resources.js +0 -197
- package/dist/services2.js +0 -3467
- package/dist/textFileEditorModel.js +0 -2985
- package/dist/tokenClassification.d.ts +0 -7
- package/dist/tokenClassification.js +0 -277
- package/dist/variableResolver.js +0 -1711
- package/dist/workbenchThemeService.js +0 -46
- package/dist/workspaceContext.js +0 -50
- /package/dist/{languageConfiguration.d.ts → preferences.d.ts} +0 -0
package/dist/files.js
CHANGED
|
@@ -1,269 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { b$ as SaveSourceRegistry, c0 as IWorkingCopyBackupService, I as IWorkingCopyService, bP as ILanguageDetectionService, c1 as IUntitledTextEditorService, bL as ILifecycleService, c2 as IFileDialogService, c3 as IFilesConfigurationService, c4 as IElevatedFileService, c5 as IDecorationsService, u as unsupported, D as Disposable$1 } from './missing-services.js';
|
|
4
|
-
import { C as CancellationTokenSource } from './cancellation.js';
|
|
1
|
+
import { __decorate, EditorExtensions, FILES_EXCLUDE_CONFIG, FILES_ASSOCIATIONS_CONFIG, SUPPORTED_ENCODINGS, AutoSaveConfiguration, Emitter, createFileSystemProviderError, AbstractTextResourceEditorInput, DEFAULT_EDITOR_ASSOCIATION, findViewStateForEditor, isResourceEditorInput, __param, HotExitConfiguration, FileType, FileSystemProviderError, FileSystemProviderErrorCode, IFileService, ITextFileService, BrowserTextFileService, EditorModel, getLargeFileConfirmationLimit, ByteSize, IFilesConfigurationService, IEditorService, IPathService, IUriIdentityService, IHostService, ResourceQueue, mark, FileChangesEvent, FileOperationError, hasOpenReadWriteCloseCapability, hasReadWriteCapability, hasFileReadStreamCapability, toFileSystemProviderErrorCode, ensureFileSystemProviderError, FilePermission, etag, FileOperationEvent, isReadableStream, peekStream, peekReadable, bufferToReadable, toFileOperationResult, ETAG_DISABLED, streamToBuffer, hasFileAtomicReadCapability, consumeStream, NotModifiedSinceFileOperationError, TooLargeFileOperationError, transform, hasFileFolderCopyCapability, hasFileCloneCapability, isReadableBufferedStream, listenStream, bufferedStreamToBuffer, readableToBuffer, isEqual as isEqual$1, CancellationTokenSource, newWriteableBufferStream, newWriteableStream } from './polyfill.js';
|
|
2
|
+
export { FileChangeType$1 as FileChangeType, FileSystemProviderCapabilities } from './polyfill.js';
|
|
5
3
|
import { VSBuffer } from 'monaco-editor/esm/vs/base/common/buffer.js';
|
|
6
|
-
import {
|
|
4
|
+
import { canceled, ErrorNoTelemetry } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
7
5
|
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { Promises, raceCancellation } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
6
|
+
import { Disposable, DisposableStore, dispose, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
7
|
+
import { RunOnceScheduler, Promises } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
11
8
|
import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
|
|
12
|
-
import {
|
|
9
|
+
import { basename, dirname, isEqual, relativePath, joinPath, isAbsolutePath, extUri, extUriIgnorePathCase, basenameOrAuthority, isEqualOrParent } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
13
10
|
import { TernarySearchTree } from 'monaco-editor/esm/vs/base/common/ternarySearchTree.js';
|
|
14
|
-
import {
|
|
11
|
+
import { coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
15
12
|
import { hash } from 'monaco-editor/esm/vs/base/common/hash.js';
|
|
16
13
|
import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
|
|
17
14
|
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
18
15
|
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
|
|
26
|
-
import { ITextResourceConfigurationService } from 'monaco-editor/esm/vs/editor/common/services/textResourceConfiguration.js';
|
|
16
|
+
import { FILE_EDITOR_INPUT_ID, BINARY_TEXT_FILE_MODE, BINARY_FILE_EDITOR_ID, TEXT_FILE_EDITOR_ID } from './files2.js';
|
|
17
|
+
import { Mimes } from 'monaco-editor/esm/vs/base/common/mime.js';
|
|
18
|
+
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
19
|
+
import { createTextBufferFactory } from 'monaco-editor/esm/vs/editor/common/model/textModel.js';
|
|
20
|
+
import { createDecorator, IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
21
|
+
import { ITextModelService } from 'monaco-editor/esm/vs/editor/common/services/resolverService.js';
|
|
27
22
|
import { ILabelService } from 'monaco-editor/esm/vs/platform/label/common/label.js';
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import { PLAINTEXT_LANGUAGE_ID, PLAINTEXT_EXTENSION } from 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
|
|
23
|
+
import { ITextResourceConfigurationService } from 'monaco-editor/esm/vs/editor/common/services/textResourceConfiguration.js';
|
|
24
|
+
import { assertIsDefined } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
25
|
+
import { equalsIgnoreCase, startsWithIgnoreCase, rtrim } from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
26
|
+
import { posix } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
27
|
+
import { memoize } from 'monaco-editor/esm/vs/base/common/decorators.js';
|
|
34
28
|
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import { t as toLocalResource } from './resources.js';
|
|
40
|
-
import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
|
|
41
|
-
import { extname } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
42
|
-
import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
|
|
43
|
-
import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
|
|
44
|
-
import { WORKSPACE_EXTENSION, IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
45
|
-
import { registerSingleton } from 'monaco-editor/esm/vs/platform/instantiation/common/extensions.js';
|
|
46
|
-
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
47
|
-
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
48
|
-
import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
|
|
29
|
+
import { ResourceMap } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
30
|
+
import { equals, deepClone } from 'monaco-editor/esm/vs/base/common/objects.js';
|
|
31
|
+
import { parse } from 'monaco-editor/esm/vs/base/common/glob.js';
|
|
32
|
+
import { IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
49
33
|
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.initialValue = initialValue;
|
|
62
|
-
this.preferredLanguageId = preferredLanguageId;
|
|
63
|
-
this.preferredEncoding = preferredEncoding;
|
|
64
|
-
this.workingCopyBackupService = workingCopyBackupService;
|
|
65
|
-
this.textResourceConfigurationService = textResourceConfigurationService;
|
|
66
|
-
this.workingCopyService = workingCopyService;
|
|
67
|
-
this.textFileService = textFileService;
|
|
68
|
-
this.labelService = labelService;
|
|
69
|
-
this.editorService = editorService;
|
|
70
|
-
this._onDidChangeContent = this._register(( (new Emitter())));
|
|
71
|
-
this.onDidChangeContent = this._onDidChangeContent.event;
|
|
72
|
-
this._onDidChangeName = this._register(( (new Emitter())));
|
|
73
|
-
this.onDidChangeName = this._onDidChangeName.event;
|
|
74
|
-
this._onDidChangeDirty = this._register(( (new Emitter())));
|
|
75
|
-
this.onDidChangeDirty = this._onDidChangeDirty.event;
|
|
76
|
-
this._onDidChangeEncoding = this._register(( (new Emitter())));
|
|
77
|
-
this.onDidChangeEncoding = this._onDidChangeEncoding.event;
|
|
78
|
-
this._onDidSave = this._register(( (new Emitter())));
|
|
79
|
-
this.onDidSave = this._onDidSave.event;
|
|
80
|
-
this._onDidRevert = this._register(( (new Emitter())));
|
|
81
|
-
this.onDidRevert = this._onDidRevert.event;
|
|
82
|
-
this.typeId = NO_TYPE_ID;
|
|
83
|
-
this.capabilities = 2 ;
|
|
84
|
-
this.configuredLabelFormat = 'content';
|
|
85
|
-
this.cachedModelFirstLineWords = undefined;
|
|
86
|
-
this.dirty = this.hasAssociatedFilePath || !!this.initialValue;
|
|
87
|
-
this._register(this.workingCopyService.registerWorkingCopy(this));
|
|
88
|
-
if (preferredLanguageId) {
|
|
89
|
-
this.setLanguageId(preferredLanguageId);
|
|
90
|
-
}
|
|
91
|
-
this.onConfigurationChange(undefined, false);
|
|
92
|
-
this.registerListeners();
|
|
93
|
-
}
|
|
94
|
-
registerListeners() {
|
|
95
|
-
this._register(this.textResourceConfigurationService.onDidChangeConfiguration(e => this.onConfigurationChange(e, true)));
|
|
96
|
-
}
|
|
97
|
-
onConfigurationChange(e, fromEvent) {
|
|
98
|
-
if (!e || e.affectsConfiguration(this.resource, 'files.encoding')) {
|
|
99
|
-
const configuredEncoding = this.textResourceConfigurationService.getValue(this.resource, 'files.encoding');
|
|
100
|
-
if (this.configuredEncoding !== configuredEncoding && typeof configuredEncoding === 'string') {
|
|
101
|
-
this.configuredEncoding = configuredEncoding;
|
|
102
|
-
if (fromEvent && !this.preferredEncoding) {
|
|
103
|
-
this._onDidChangeEncoding.fire();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (!e || e.affectsConfiguration(this.resource, 'workbench.editor.untitled.labelFormat')) {
|
|
108
|
-
const configuredLabelFormat = this.textResourceConfigurationService.getValue(this.resource, 'workbench.editor.untitled.labelFormat');
|
|
109
|
-
if (this.configuredLabelFormat !== configuredLabelFormat && (configuredLabelFormat === 'content' || configuredLabelFormat === 'name')) {
|
|
110
|
-
this.configuredLabelFormat = configuredLabelFormat;
|
|
111
|
-
if (fromEvent) {
|
|
112
|
-
this._onDidChangeName.fire();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
setLanguageId(languageId, source) {
|
|
118
|
-
const actualLanguage = languageId === UntitledTextEditorModel.ACTIVE_EDITOR_LANGUAGE_ID
|
|
119
|
-
? this.editorService.activeTextEditorLanguageId
|
|
120
|
-
: languageId;
|
|
121
|
-
this.preferredLanguageId = actualLanguage;
|
|
122
|
-
if (actualLanguage) {
|
|
123
|
-
super.setLanguageId(actualLanguage, source);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
getLanguageId() {
|
|
127
|
-
if (this.textEditorModel) {
|
|
128
|
-
return this.textEditorModel.getLanguageId();
|
|
129
|
-
}
|
|
130
|
-
return this.preferredLanguageId;
|
|
131
|
-
}
|
|
132
|
-
getEncoding() {
|
|
133
|
-
return this.preferredEncoding || this.configuredEncoding;
|
|
134
|
-
}
|
|
135
|
-
async setEncoding(encoding) {
|
|
136
|
-
const oldEncoding = this.getEncoding();
|
|
137
|
-
this.preferredEncoding = encoding;
|
|
138
|
-
if (oldEncoding !== this.preferredEncoding) {
|
|
139
|
-
this._onDidChangeEncoding.fire();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
isDirty() {
|
|
143
|
-
return this.dirty;
|
|
144
|
-
}
|
|
145
|
-
setDirty(dirty) {
|
|
146
|
-
if (this.dirty === dirty) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
this.dirty = dirty;
|
|
150
|
-
this._onDidChangeDirty.fire();
|
|
151
|
-
}
|
|
152
|
-
async save(options) {
|
|
153
|
-
const target = await this.textFileService.save(this.resource, options);
|
|
154
|
-
if (target) {
|
|
155
|
-
this._onDidSave.fire({ reason: options?.reason, source: options?.source });
|
|
156
|
-
}
|
|
157
|
-
return !!target;
|
|
158
|
-
}
|
|
159
|
-
async revert() {
|
|
160
|
-
this.setDirty(false);
|
|
161
|
-
this._onDidRevert.fire();
|
|
162
|
-
this.dispose();
|
|
163
|
-
}
|
|
164
|
-
async backup(token) {
|
|
165
|
-
let content = undefined;
|
|
166
|
-
if (this.isResolved()) {
|
|
167
|
-
content = await this.textFileService.getEncodedReadable(this.resource, withNullAsUndefined(this.createSnapshot()), { encoding: UTF8 });
|
|
168
|
-
}
|
|
169
|
-
else if (typeof this.initialValue === 'string') {
|
|
170
|
-
content = bufferToReadable(VSBuffer.fromString(this.initialValue));
|
|
171
|
-
}
|
|
172
|
-
return { content };
|
|
173
|
-
}
|
|
174
|
-
async resolve() {
|
|
175
|
-
let createdUntitledModel = false;
|
|
176
|
-
let hasBackup = false;
|
|
177
|
-
if (!this.textEditorModel) {
|
|
178
|
-
let untitledContents;
|
|
179
|
-
const backup = await this.workingCopyBackupService.resolve(this);
|
|
180
|
-
if (backup) {
|
|
181
|
-
untitledContents = backup.value;
|
|
182
|
-
hasBackup = true;
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
untitledContents = bufferToStream(VSBuffer.fromString(this.initialValue || ''));
|
|
186
|
-
}
|
|
187
|
-
const untitledContentsFactory = await createTextBufferFactoryFromStream(await this.textFileService.getDecodedStream(this.resource, untitledContents, { encoding: UTF8 }));
|
|
188
|
-
this.createTextEditorModel(untitledContentsFactory, this.resource, this.preferredLanguageId);
|
|
189
|
-
createdUntitledModel = true;
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
this.updateTextEditorModel(undefined, this.preferredLanguageId);
|
|
193
|
-
}
|
|
194
|
-
const textEditorModel = assertIsDefined(this.textEditorModel);
|
|
195
|
-
this.installModelListeners(textEditorModel);
|
|
196
|
-
if (createdUntitledModel) {
|
|
197
|
-
if (hasBackup || this.initialValue) {
|
|
198
|
-
this.updateNameFromFirstLine(textEditorModel);
|
|
199
|
-
}
|
|
200
|
-
this.setDirty(this.hasAssociatedFilePath || !!hasBackup || !!this.initialValue);
|
|
201
|
-
if (hasBackup || this.initialValue) {
|
|
202
|
-
this._onDidChangeContent.fire();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return super.resolve();
|
|
206
|
-
}
|
|
207
|
-
installModelListeners(model) {
|
|
208
|
-
this._register(model.onDidChangeContent(e => this.onModelContentChanged(model, e)));
|
|
209
|
-
this._register(model.onDidChangeLanguage(() => this.onConfigurationChange(undefined, true)));
|
|
210
|
-
super.installModelListeners(model);
|
|
211
|
-
}
|
|
212
|
-
onModelContentChanged(textEditorModel, e) {
|
|
213
|
-
if (!this.hasAssociatedFilePath && textEditorModel.getLineCount() === 1 && textEditorModel.getLineContent(1) === '') {
|
|
214
|
-
this.setDirty(false);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
this.setDirty(true);
|
|
218
|
-
}
|
|
219
|
-
if (e.changes.some(change => (change.range.startLineNumber === 1 || change.range.endLineNumber === 1) && change.range.startColumn <= UntitledTextEditorModel.FIRST_LINE_NAME_CANDIDATE_MAX_LENGTH)) {
|
|
220
|
-
this.updateNameFromFirstLine(textEditorModel);
|
|
221
|
-
}
|
|
222
|
-
this._onDidChangeContent.fire();
|
|
223
|
-
this.autoDetectLanguage();
|
|
224
|
-
}
|
|
225
|
-
updateNameFromFirstLine(textEditorModel) {
|
|
226
|
-
if (this.hasAssociatedFilePath) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
let modelFirstWordsCandidate = undefined;
|
|
230
|
-
let firstLineText = textEditorModel
|
|
231
|
-
.getValueInRange({
|
|
232
|
-
startLineNumber: 1,
|
|
233
|
-
endLineNumber: 1,
|
|
234
|
-
startColumn: 1,
|
|
235
|
-
endColumn: UntitledTextEditorModel.FIRST_LINE_NAME_CANDIDATE_MAX_LENGTH + 1
|
|
236
|
-
})
|
|
237
|
-
.trim().replace(/\s+/g, ' ');
|
|
238
|
-
firstLineText = firstLineText.substr(0, getCharContainingOffset(
|
|
239
|
-
firstLineText, UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH)[0]);
|
|
240
|
-
if (firstLineText && ensureValidWordDefinition().exec(firstLineText)) {
|
|
241
|
-
modelFirstWordsCandidate = firstLineText;
|
|
242
|
-
}
|
|
243
|
-
if (modelFirstWordsCandidate !== this.cachedModelFirstLineWords) {
|
|
244
|
-
this.cachedModelFirstLineWords = modelFirstWordsCandidate;
|
|
245
|
-
this._onDidChangeName.fire();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
isReadonly() {
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH = 40;
|
|
253
|
-
UntitledTextEditorModel.FIRST_LINE_NAME_CANDIDATE_MAX_LENGTH = UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH * 10;
|
|
254
|
-
UntitledTextEditorModel.ACTIVE_EDITOR_LANGUAGE_ID = '${activeEditorLanguage}';
|
|
255
|
-
UntitledTextEditorModel = ( (__decorate([
|
|
256
|
-
( (__param(5, ILanguageService))),
|
|
257
|
-
( (__param(6, IModelService))),
|
|
258
|
-
( (__param(7, IWorkingCopyBackupService))),
|
|
259
|
-
( (__param(8, ITextResourceConfigurationService))),
|
|
260
|
-
( (__param(9, IWorkingCopyService))),
|
|
261
|
-
( (__param(10, ITextFileService))),
|
|
262
|
-
( (__param(11, ILabelService))),
|
|
263
|
-
( (__param(12, IEditorService))),
|
|
264
|
-
( (__param(13, ILanguageDetectionService))),
|
|
265
|
-
( (__param(14, IAccessibilityService)))
|
|
266
|
-
], UntitledTextEditorModel)));
|
|
34
|
+
import { IUndoRedoService, UndoRedoSource } from 'monaco-editor/esm/vs/platform/undoRedo/common/undoRedo.js';
|
|
35
|
+
import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
|
|
36
|
+
import { IBulkEditService } from 'monaco-editor/esm/vs/editor/browser/services/bulkEditService.js';
|
|
37
|
+
import { IProgressService } from 'monaco-editor/esm/vs/platform/progress/common/progress.js';
|
|
38
|
+
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
39
|
+
import { isWeb, isNative } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
40
|
+
import { editorConfigurationBaseNode } from 'monaco-editor/esm/vs/editor/common/config/editorConfigurationSchema.js';
|
|
41
|
+
import { RedoCommand } from 'monaco-editor/esm/vs/editor/browser/editorExtensions.js';
|
|
42
|
+
import { ModesRegistry } from 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
|
|
43
|
+
import { Extensions } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
44
|
+
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
267
45
|
async function readFileIntoStream(provider, resource, target, transformer, options, token) {
|
|
268
46
|
let error = undefined;
|
|
269
47
|
try {
|
|
@@ -1423,1021 +1201,1740 @@ class InMemoryFileSystemProvider extends Disposable {
|
|
|
1423
1201
|
}, 5);
|
|
1424
1202
|
}
|
|
1425
1203
|
}
|
|
1426
|
-
let
|
|
1427
|
-
constructor(
|
|
1428
|
-
super();
|
|
1429
|
-
this.progressService = progressService;
|
|
1430
|
-
this.logService = logService;
|
|
1431
|
-
this.saveParticipants = [];
|
|
1432
|
-
}
|
|
1433
|
-
addSaveParticipant(participant) {
|
|
1434
|
-
const remove = insert(this.saveParticipants, participant);
|
|
1435
|
-
return toDisposable(() => remove());
|
|
1436
|
-
}
|
|
1437
|
-
participate(model, context, token) {
|
|
1438
|
-
const cts = ( (new CancellationTokenSource(token)));
|
|
1439
|
-
return this.progressService.withProgress({
|
|
1440
|
-
title: ( (localize('saveParticipants', "Saving '{0}'", model.name))),
|
|
1441
|
-
location: 15 ,
|
|
1442
|
-
cancellable: true,
|
|
1443
|
-
delay: model.isDirty() ? 3000 : 5000
|
|
1444
|
-
}, async (progress) => {
|
|
1445
|
-
model.textEditorModel?.pushStackElement();
|
|
1446
|
-
for (const saveParticipant of this.saveParticipants) {
|
|
1447
|
-
if (cts.token.isCancellationRequested || !model.textEditorModel ) {
|
|
1448
|
-
break;
|
|
1449
|
-
}
|
|
1450
|
-
try {
|
|
1451
|
-
const promise = saveParticipant.participate(model, context, progress, cts.token);
|
|
1452
|
-
await raceCancellation(promise, cts.token);
|
|
1453
|
-
}
|
|
1454
|
-
catch (err) {
|
|
1455
|
-
this.logService.error(err);
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
model.textEditorModel?.pushStackElement();
|
|
1459
|
-
}, () => {
|
|
1460
|
-
cts.dispose(true);
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
dispose() {
|
|
1464
|
-
this.saveParticipants.splice(0, this.saveParticipants.length);
|
|
1465
|
-
}
|
|
1466
|
-
};
|
|
1467
|
-
TextFileSaveParticipant = ( (__decorate([
|
|
1468
|
-
( (__param(0, IProgressService))),
|
|
1469
|
-
( (__param(1, ILogService)))
|
|
1470
|
-
], TextFileSaveParticipant)));
|
|
1471
|
-
let TextFileEditorModelManager = class TextFileEditorModelManager extends Disposable {
|
|
1472
|
-
get models() {
|
|
1473
|
-
return [...( (this.mapResourceToModel.values()))];
|
|
1474
|
-
}
|
|
1475
|
-
constructor(instantiationService, fileService, notificationService, workingCopyFileService, uriIdentityService) {
|
|
1204
|
+
let BinaryEditorModel = class BinaryEditorModel extends EditorModel {
|
|
1205
|
+
constructor(resource, name, fileService) {
|
|
1476
1206
|
super();
|
|
1477
|
-
this.
|
|
1207
|
+
this.resource = resource;
|
|
1208
|
+
this.name = name;
|
|
1478
1209
|
this.fileService = fileService;
|
|
1479
|
-
this.
|
|
1480
|
-
this.workingCopyFileService = workingCopyFileService;
|
|
1481
|
-
this.uriIdentityService = uriIdentityService;
|
|
1482
|
-
this._onDidCreate = this._register(( (new Emitter())));
|
|
1483
|
-
this.onDidCreate = this._onDidCreate.event;
|
|
1484
|
-
this._onDidResolve = this._register(( (new Emitter())));
|
|
1485
|
-
this.onDidResolve = this._onDidResolve.event;
|
|
1486
|
-
this._onDidRemove = this._register(( (new Emitter())));
|
|
1487
|
-
this.onDidRemove = this._onDidRemove.event;
|
|
1488
|
-
this._onDidChangeDirty = this._register(( (new Emitter())));
|
|
1489
|
-
this.onDidChangeDirty = this._onDidChangeDirty.event;
|
|
1490
|
-
this._onDidChangeReadonly = this._register(( (new Emitter())));
|
|
1491
|
-
this.onDidChangeReadonly = this._onDidChangeReadonly.event;
|
|
1492
|
-
this._onDidChangeOrphaned = this._register(( (new Emitter())));
|
|
1493
|
-
this.onDidChangeOrphaned = this._onDidChangeOrphaned.event;
|
|
1494
|
-
this._onDidSaveError = this._register(( (new Emitter())));
|
|
1495
|
-
this.onDidSaveError = this._onDidSaveError.event;
|
|
1496
|
-
this._onDidSave = this._register(( (new Emitter())));
|
|
1497
|
-
this.onDidSave = this._onDidSave.event;
|
|
1498
|
-
this._onDidRevert = this._register(( (new Emitter())));
|
|
1499
|
-
this.onDidRevert = this._onDidRevert.event;
|
|
1500
|
-
this._onDidChangeEncoding = this._register(( (new Emitter())));
|
|
1501
|
-
this.onDidChangeEncoding = this._onDidChangeEncoding.event;
|
|
1502
|
-
this.mapResourceToModel = ( (new ResourceMap()));
|
|
1503
|
-
this.mapResourceToModelListeners = ( (new ResourceMap()));
|
|
1504
|
-
this.mapResourceToDisposeListener = ( (new ResourceMap()));
|
|
1505
|
-
this.mapResourceToPendingModelResolvers = ( (new ResourceMap()));
|
|
1506
|
-
this.modelResolveQueue = this._register(( (new ResourceQueue())));
|
|
1507
|
-
this.saveErrorHandler = (() => {
|
|
1508
|
-
const notificationService = this.notificationService;
|
|
1509
|
-
return {
|
|
1510
|
-
onSaveError(error, model) {
|
|
1511
|
-
notificationService.error(( (localize(
|
|
1512
|
-
{ key: 'genericSaveError', comment: ['{0} is the resource that failed to save and {1} the error message'] },
|
|
1513
|
-
"Failed to save '{0}': {1}",
|
|
1514
|
-
model.name,
|
|
1515
|
-
toErrorMessage(error, false)
|
|
1516
|
-
))));
|
|
1517
|
-
}
|
|
1518
|
-
};
|
|
1519
|
-
})();
|
|
1520
|
-
this.mapCorrelationIdToModelsToRestore = ( (new Map()));
|
|
1521
|
-
this.saveParticipants = this._register(this.instantiationService.createInstance(TextFileSaveParticipant));
|
|
1522
|
-
this.registerListeners();
|
|
1523
|
-
}
|
|
1524
|
-
registerListeners() {
|
|
1525
|
-
this._register(this.fileService.onDidFilesChange(e => this.onDidFilesChange(e)));
|
|
1526
|
-
this._register(this.fileService.onDidChangeFileSystemProviderCapabilities(e => this.onDidChangeFileSystemProviderCapabilities(e)));
|
|
1527
|
-
this._register(this.fileService.onDidChangeFileSystemProviderRegistrations(e => this.onDidChangeFileSystemProviderRegistrations(e)));
|
|
1528
|
-
this._register(this.workingCopyFileService.onWillRunWorkingCopyFileOperation(e => this.onWillRunWorkingCopyFileOperation(e)));
|
|
1529
|
-
this._register(this.workingCopyFileService.onDidFailWorkingCopyFileOperation(e => this.onDidFailWorkingCopyFileOperation(e)));
|
|
1530
|
-
this._register(this.workingCopyFileService.onDidRunWorkingCopyFileOperation(e => this.onDidRunWorkingCopyFileOperation(e)));
|
|
1531
|
-
}
|
|
1532
|
-
onDidFilesChange(e) {
|
|
1533
|
-
for (const model of this.models) {
|
|
1534
|
-
if (model.isDirty()) {
|
|
1535
|
-
continue;
|
|
1536
|
-
}
|
|
1537
|
-
if (e.contains(model.resource, 0 , 1 )) {
|
|
1538
|
-
this.queueModelReload(model);
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1210
|
+
this.mime = Mimes.binary;
|
|
1541
1211
|
}
|
|
1542
|
-
|
|
1543
|
-
this.
|
|
1212
|
+
getName() {
|
|
1213
|
+
return this.name;
|
|
1544
1214
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
return;
|
|
1548
|
-
}
|
|
1549
|
-
this.queueModelReloads(e.scheme);
|
|
1550
|
-
}
|
|
1551
|
-
queueModelReloads(scheme) {
|
|
1552
|
-
for (const model of this.models) {
|
|
1553
|
-
if (model.isDirty()) {
|
|
1554
|
-
continue;
|
|
1555
|
-
}
|
|
1556
|
-
if (scheme === model.resource.scheme) {
|
|
1557
|
-
this.queueModelReload(model);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1215
|
+
getSize() {
|
|
1216
|
+
return this.size;
|
|
1560
1217
|
}
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
if (queue.size <= 1) {
|
|
1564
|
-
queue.queue(async () => {
|
|
1565
|
-
try {
|
|
1566
|
-
await this.reload(model);
|
|
1567
|
-
}
|
|
1568
|
-
catch (error) {
|
|
1569
|
-
onUnexpectedError(error);
|
|
1570
|
-
}
|
|
1571
|
-
});
|
|
1572
|
-
}
|
|
1218
|
+
getMime() {
|
|
1219
|
+
return this.mime;
|
|
1573
1220
|
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
const modelsToRestore = [];
|
|
1577
|
-
for (const { source, target } of e.files) {
|
|
1578
|
-
if (source) {
|
|
1579
|
-
if (this.uriIdentityService.extUri.isEqual(source, target)) {
|
|
1580
|
-
continue;
|
|
1581
|
-
}
|
|
1582
|
-
const sourceModels = [];
|
|
1583
|
-
for (const model of this.models) {
|
|
1584
|
-
if (this.uriIdentityService.extUri.isEqualOrParent(model.resource, source)) {
|
|
1585
|
-
sourceModels.push(model);
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
for (const sourceModel of sourceModels) {
|
|
1589
|
-
const sourceModelResource = sourceModel.resource;
|
|
1590
|
-
let targetModelResource;
|
|
1591
|
-
if (this.uriIdentityService.extUri.isEqual(sourceModelResource, source)) {
|
|
1592
|
-
targetModelResource = target;
|
|
1593
|
-
}
|
|
1594
|
-
else {
|
|
1595
|
-
targetModelResource = joinPath(target, sourceModelResource.path.substr(source.path.length + 1));
|
|
1596
|
-
}
|
|
1597
|
-
modelsToRestore.push({
|
|
1598
|
-
source: sourceModelResource,
|
|
1599
|
-
target: targetModelResource,
|
|
1600
|
-
languageId: sourceModel.getLanguageId(),
|
|
1601
|
-
encoding: sourceModel.getEncoding(),
|
|
1602
|
-
snapshot: sourceModel.isDirty() ? sourceModel.createSnapshot() : undefined
|
|
1603
|
-
});
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
this.mapCorrelationIdToModelsToRestore.set(e.correlationId, modelsToRestore);
|
|
1608
|
-
}
|
|
1221
|
+
getETag() {
|
|
1222
|
+
return this.etag;
|
|
1609
1223
|
}
|
|
1610
|
-
|
|
1611
|
-
if ((
|
|
1612
|
-
const
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
if (model.snapshot) {
|
|
1617
|
-
this.get(model.source)?.setDirty(true);
|
|
1618
|
-
}
|
|
1619
|
-
});
|
|
1224
|
+
async resolve() {
|
|
1225
|
+
if (this.fileService.hasProvider(this.resource)) {
|
|
1226
|
+
const stat = await this.fileService.stat(this.resource);
|
|
1227
|
+
this.etag = stat.etag;
|
|
1228
|
+
if (typeof stat.size === 'number') {
|
|
1229
|
+
this.size = stat.size;
|
|
1620
1230
|
}
|
|
1621
1231
|
}
|
|
1232
|
+
return super.resolve();
|
|
1622
1233
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
await model.revert();
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
})());
|
|
1634
|
-
break;
|
|
1635
|
-
case 2 :
|
|
1636
|
-
case 3 :
|
|
1637
|
-
e.waitUntil((async () => {
|
|
1638
|
-
const modelsToRestore = this.mapCorrelationIdToModelsToRestore.get(e.correlationId);
|
|
1639
|
-
if (modelsToRestore) {
|
|
1640
|
-
this.mapCorrelationIdToModelsToRestore.delete(e.correlationId);
|
|
1641
|
-
await Promises.settled(( (modelsToRestore.map(async (modelToRestore) => {
|
|
1642
|
-
const restoredModel = await this.resolve(modelToRestore.target, {
|
|
1643
|
-
reload: { async: false },
|
|
1644
|
-
contents: modelToRestore.snapshot ? createTextBufferFactoryFromSnapshot(modelToRestore.snapshot) : undefined,
|
|
1645
|
-
encoding: modelToRestore.encoding
|
|
1646
|
-
});
|
|
1647
|
-
if (modelToRestore.languageId &&
|
|
1648
|
-
modelToRestore.languageId !== PLAINTEXT_LANGUAGE_ID &&
|
|
1649
|
-
restoredModel.getLanguageId() === PLAINTEXT_LANGUAGE_ID &&
|
|
1650
|
-
extname$1(modelToRestore.target) !== PLAINTEXT_EXTENSION) {
|
|
1651
|
-
restoredModel.updateTextEditorModel(undefined, modelToRestore.languageId);
|
|
1652
|
-
}
|
|
1653
|
-
}))));
|
|
1654
|
-
}
|
|
1655
|
-
})());
|
|
1656
|
-
break;
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
get(resource) {
|
|
1660
|
-
return this.mapResourceToModel.get(resource);
|
|
1661
|
-
}
|
|
1662
|
-
has(resource) {
|
|
1663
|
-
return this.mapResourceToModel.has(resource);
|
|
1664
|
-
}
|
|
1665
|
-
async reload(model) {
|
|
1666
|
-
await this.joinPendingResolves(model.resource);
|
|
1667
|
-
if (model.isDirty() || model.isDisposed() || !this.has(model.resource)) {
|
|
1668
|
-
return;
|
|
1669
|
-
}
|
|
1670
|
-
await this.doResolve(model, { reload: { async: false } });
|
|
1234
|
+
};
|
|
1235
|
+
BinaryEditorModel = ( (__decorate([
|
|
1236
|
+
( (__param(2, IFileService)))
|
|
1237
|
+
], BinaryEditorModel)));
|
|
1238
|
+
let FileEditorInput = class FileEditorInput extends AbstractTextResourceEditorInput {
|
|
1239
|
+
get typeId() {
|
|
1240
|
+
return FILE_EDITOR_INPUT_ID;
|
|
1671
1241
|
}
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
if (pendingResolve) {
|
|
1675
|
-
await pendingResolve;
|
|
1676
|
-
}
|
|
1677
|
-
return this.doResolve(resource, options);
|
|
1242
|
+
get editorId() {
|
|
1243
|
+
return DEFAULT_EDITOR_ASSOCIATION.id;
|
|
1678
1244
|
}
|
|
1679
|
-
|
|
1680
|
-
let
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1245
|
+
get capabilities() {
|
|
1246
|
+
let capabilities = 32 ;
|
|
1247
|
+
if (this.model) {
|
|
1248
|
+
if (this.model.isReadonly()) {
|
|
1249
|
+
capabilities |= 2 ;
|
|
1250
|
+
}
|
|
1685
1251
|
}
|
|
1686
1252
|
else {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
let modelResolve;
|
|
1691
|
-
let didCreateModel = false;
|
|
1692
|
-
if (model) {
|
|
1693
|
-
if (options?.contents) {
|
|
1694
|
-
modelResolve = model.resolve(options);
|
|
1695
|
-
}
|
|
1696
|
-
else if (options?.reload) {
|
|
1697
|
-
if (options.reload.async) {
|
|
1698
|
-
modelResolve = Promise.resolve();
|
|
1699
|
-
(async () => {
|
|
1700
|
-
try {
|
|
1701
|
-
await model.resolve(options);
|
|
1702
|
-
}
|
|
1703
|
-
catch (error) {
|
|
1704
|
-
onUnexpectedError(error);
|
|
1705
|
-
}
|
|
1706
|
-
})();
|
|
1707
|
-
}
|
|
1708
|
-
else {
|
|
1709
|
-
modelResolve = model.resolve(options);
|
|
1253
|
+
if (this.fileService.hasProvider(this.resource)) {
|
|
1254
|
+
if (this.fileService.hasCapability(this.resource, 2048 )) {
|
|
1255
|
+
capabilities |= 2 ;
|
|
1710
1256
|
}
|
|
1711
1257
|
}
|
|
1712
1258
|
else {
|
|
1713
|
-
|
|
1259
|
+
capabilities |= 4 ;
|
|
1714
1260
|
}
|
|
1715
1261
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
const newModel = model = this.instantiationService.createInstance(TextFileEditorModel, resource, options ? options.encoding : undefined, options ? options.languageId : undefined);
|
|
1719
|
-
modelResolve = model.resolve(options);
|
|
1720
|
-
this.registerModel(newModel);
|
|
1262
|
+
if (!((capabilities & 2) )) {
|
|
1263
|
+
capabilities |= 128 ;
|
|
1721
1264
|
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1265
|
+
return capabilities;
|
|
1266
|
+
}
|
|
1267
|
+
constructor(resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService, textFileService, textModelResolverService, labelService, fileService, filesConfigurationService, editorService, pathService, textResourceConfigurationService) {
|
|
1268
|
+
super(resource, preferredResource, editorService, textFileService, labelService, fileService);
|
|
1269
|
+
this.instantiationService = instantiationService;
|
|
1270
|
+
this.textModelResolverService = textModelResolverService;
|
|
1271
|
+
this.filesConfigurationService = filesConfigurationService;
|
|
1272
|
+
this.pathService = pathService;
|
|
1273
|
+
this.textResourceConfigurationService = textResourceConfigurationService;
|
|
1274
|
+
this.forceOpenAs = 0 ;
|
|
1275
|
+
this.model = undefined;
|
|
1276
|
+
this.cachedTextFileModelReference = undefined;
|
|
1277
|
+
this.modelListeners = this._register(( (new DisposableStore())));
|
|
1278
|
+
this.model = this.textFileService.files.get(resource);
|
|
1279
|
+
if (preferredName) {
|
|
1280
|
+
this.setPreferredName(preferredName);
|
|
1729
1281
|
}
|
|
1730
|
-
|
|
1731
|
-
|
|
1282
|
+
if (preferredDescription) {
|
|
1283
|
+
this.setPreferredDescription(preferredDescription);
|
|
1732
1284
|
}
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
model.dispose();
|
|
1736
|
-
}
|
|
1737
|
-
throw error;
|
|
1285
|
+
if (preferredEncoding) {
|
|
1286
|
+
this.setPreferredEncoding(preferredEncoding);
|
|
1738
1287
|
}
|
|
1739
|
-
|
|
1740
|
-
this.
|
|
1288
|
+
if (preferredLanguageId) {
|
|
1289
|
+
this.setPreferredLanguageId(preferredLanguageId);
|
|
1741
1290
|
}
|
|
1742
|
-
if (
|
|
1743
|
-
|
|
1291
|
+
if (typeof preferredContents === 'string') {
|
|
1292
|
+
this.setPreferredContents(preferredContents);
|
|
1744
1293
|
}
|
|
1745
|
-
|
|
1746
|
-
|
|
1294
|
+
this._register(this.textFileService.files.onDidCreate(model => this.onDidCreateTextFileModel(model)));
|
|
1295
|
+
if (this.model) {
|
|
1296
|
+
this.registerModelListeners(this.model);
|
|
1747
1297
|
}
|
|
1748
|
-
return model;
|
|
1749
1298
|
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1299
|
+
onDidCreateTextFileModel(model) {
|
|
1300
|
+
if (isEqual(model.resource, this.resource)) {
|
|
1301
|
+
this.model = model;
|
|
1302
|
+
this.registerModelListeners(model);
|
|
1754
1303
|
}
|
|
1755
|
-
return this.doJoinPendingResolves(resource);
|
|
1756
1304
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
await nextPendingModelResolve;
|
|
1767
|
-
}
|
|
1768
|
-
catch (error) {
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1305
|
+
registerModelListeners(model) {
|
|
1306
|
+
this.modelListeners.clear();
|
|
1307
|
+
this.modelListeners.add(model.onDidChangeDirty(() => this._onDidChangeDirty.fire()));
|
|
1308
|
+
this.modelListeners.add(model.onDidChangeReadonly(() => this._onDidChangeCapabilities.fire()));
|
|
1309
|
+
this.modelListeners.add(model.onDidSaveError(() => this._onDidChangeDirty.fire()));
|
|
1310
|
+
this.modelListeners.add(Event.once(model.onWillDispose)(() => {
|
|
1311
|
+
this.modelListeners.clear();
|
|
1312
|
+
this.model = undefined;
|
|
1313
|
+
}));
|
|
1771
1314
|
}
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
modelListeners.add(model.onDidResolve(reason => this._onDidResolve.fire({ model, reason })));
|
|
1775
|
-
modelListeners.add(model.onDidChangeDirty(() => this._onDidChangeDirty.fire(model)));
|
|
1776
|
-
modelListeners.add(model.onDidChangeReadonly(() => this._onDidChangeReadonly.fire(model)));
|
|
1777
|
-
modelListeners.add(model.onDidChangeOrphaned(() => this._onDidChangeOrphaned.fire(model)));
|
|
1778
|
-
modelListeners.add(model.onDidSaveError(() => this._onDidSaveError.fire(model)));
|
|
1779
|
-
modelListeners.add(model.onDidSave(e => this._onDidSave.fire({ model, ...e })));
|
|
1780
|
-
modelListeners.add(model.onDidRevert(() => this._onDidRevert.fire(model)));
|
|
1781
|
-
modelListeners.add(model.onDidChangeEncoding(() => this._onDidChangeEncoding.fire(model)));
|
|
1782
|
-
this.mapResourceToModelListeners.set(model.resource, modelListeners);
|
|
1315
|
+
getName() {
|
|
1316
|
+
return this.preferredName || super.getName();
|
|
1783
1317
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
if (knownModel === model) {
|
|
1318
|
+
setPreferredName(name) {
|
|
1319
|
+
if (!this.allowLabelOverride()) {
|
|
1787
1320
|
return;
|
|
1788
1321
|
}
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
this.mapResourceToDisposeListener.set(resource, model.onWillDispose(() => this.remove(resource)));
|
|
1793
|
-
}
|
|
1794
|
-
remove(resource) {
|
|
1795
|
-
const removed = this.mapResourceToModel.delete(resource);
|
|
1796
|
-
const disposeListener = this.mapResourceToDisposeListener.get(resource);
|
|
1797
|
-
if (disposeListener) {
|
|
1798
|
-
dispose(disposeListener);
|
|
1799
|
-
this.mapResourceToDisposeListener.delete(resource);
|
|
1800
|
-
}
|
|
1801
|
-
const modelListener = this.mapResourceToModelListeners.get(resource);
|
|
1802
|
-
if (modelListener) {
|
|
1803
|
-
dispose(modelListener);
|
|
1804
|
-
this.mapResourceToModelListeners.delete(resource);
|
|
1805
|
-
}
|
|
1806
|
-
if (removed) {
|
|
1807
|
-
this._onDidRemove.fire(resource);
|
|
1322
|
+
if (this.preferredName !== name) {
|
|
1323
|
+
this.preferredName = name;
|
|
1324
|
+
this._onDidChangeLabel.fire();
|
|
1808
1325
|
}
|
|
1809
1326
|
}
|
|
1810
|
-
|
|
1811
|
-
return this.
|
|
1327
|
+
allowLabelOverride() {
|
|
1328
|
+
return this.resource.scheme !== this.pathService.defaultUriScheme &&
|
|
1329
|
+
this.resource.scheme !== Schemas.vscodeUserData &&
|
|
1330
|
+
this.resource.scheme !== Schemas.file &&
|
|
1331
|
+
this.resource.scheme !== Schemas.vscodeRemote;
|
|
1812
1332
|
}
|
|
1813
|
-
|
|
1814
|
-
return this.
|
|
1333
|
+
getPreferredName() {
|
|
1334
|
+
return this.preferredName;
|
|
1815
1335
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
(!this.mapResourceToPendingModelResolvers.has(model.resource) && !model.isDirty())) {
|
|
1819
|
-
return true;
|
|
1820
|
-
}
|
|
1821
|
-
return this.doCanDispose(model);
|
|
1336
|
+
getDescription(verbosity) {
|
|
1337
|
+
return this.preferredDescription || super.getDescription(verbosity);
|
|
1822
1338
|
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
await pendingResolve;
|
|
1827
|
-
return this.canDispose(model);
|
|
1339
|
+
setPreferredDescription(description) {
|
|
1340
|
+
if (!this.allowLabelOverride()) {
|
|
1341
|
+
return;
|
|
1828
1342
|
}
|
|
1829
|
-
if (
|
|
1830
|
-
|
|
1831
|
-
|
|
1343
|
+
if (this.preferredDescription !== description) {
|
|
1344
|
+
this.preferredDescription = description;
|
|
1345
|
+
this._onDidChangeLabel.fire();
|
|
1832
1346
|
}
|
|
1833
|
-
return true;
|
|
1834
1347
|
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
this.mapResourceToModel.clear();
|
|
1838
|
-
this.mapResourceToPendingModelResolvers.clear();
|
|
1839
|
-
dispose(( (this.mapResourceToDisposeListener.values())));
|
|
1840
|
-
this.mapResourceToDisposeListener.clear();
|
|
1841
|
-
dispose(( (this.mapResourceToModelListeners.values())));
|
|
1842
|
-
this.mapResourceToModelListeners.clear();
|
|
1843
|
-
}
|
|
1844
|
-
};
|
|
1845
|
-
TextFileEditorModelManager = ( (__decorate([
|
|
1846
|
-
( (__param(0, IInstantiationService))),
|
|
1847
|
-
( (__param(1, IFileService))),
|
|
1848
|
-
( (__param(2, INotificationService))),
|
|
1849
|
-
( (__param(3, IWorkingCopyFileService))),
|
|
1850
|
-
( (__param(4, IUriIdentityService)))
|
|
1851
|
-
], TextFileEditorModelManager)));
|
|
1852
|
-
let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
1853
|
-
constructor(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, codeEditorService, pathService, workingCopyFileService, uriIdentityService, languageService, logService, elevatedFileService, decorationsService) {
|
|
1854
|
-
super();
|
|
1855
|
-
this.fileService = fileService;
|
|
1856
|
-
this.untitledTextEditorService = untitledTextEditorService;
|
|
1857
|
-
this.lifecycleService = lifecycleService;
|
|
1858
|
-
this.instantiationService = instantiationService;
|
|
1859
|
-
this.modelService = modelService;
|
|
1860
|
-
this.environmentService = environmentService;
|
|
1861
|
-
this.dialogService = dialogService;
|
|
1862
|
-
this.fileDialogService = fileDialogService;
|
|
1863
|
-
this.textResourceConfigurationService = textResourceConfigurationService;
|
|
1864
|
-
this.filesConfigurationService = filesConfigurationService;
|
|
1865
|
-
this.codeEditorService = codeEditorService;
|
|
1866
|
-
this.pathService = pathService;
|
|
1867
|
-
this.workingCopyFileService = workingCopyFileService;
|
|
1868
|
-
this.uriIdentityService = uriIdentityService;
|
|
1869
|
-
this.languageService = languageService;
|
|
1870
|
-
this.logService = logService;
|
|
1871
|
-
this.elevatedFileService = elevatedFileService;
|
|
1872
|
-
this.decorationsService = decorationsService;
|
|
1873
|
-
this.files = this._register(this.instantiationService.createInstance(TextFileEditorModelManager));
|
|
1874
|
-
this.untitled = this.untitledTextEditorService;
|
|
1875
|
-
this.provideDecorations();
|
|
1876
|
-
}
|
|
1877
|
-
provideDecorations() {
|
|
1878
|
-
this.decorationsService.registerDecorationsProvider(new (class extends Disposable {
|
|
1879
|
-
constructor(files) {
|
|
1880
|
-
super();
|
|
1881
|
-
this.files = files;
|
|
1882
|
-
this.label = ( (localize('textFileModelDecorations', "Text File Model Decorations")));
|
|
1883
|
-
this._onDidChange = this._register(( (new Emitter())));
|
|
1884
|
-
this.onDidChange = this._onDidChange.event;
|
|
1885
|
-
this.registerListeners();
|
|
1886
|
-
}
|
|
1887
|
-
registerListeners() {
|
|
1888
|
-
this._register(this.files.onDidResolve(({ model }) => {
|
|
1889
|
-
if (model.isReadonly() || model.hasState(4 )) {
|
|
1890
|
-
this._onDidChange.fire([model.resource]);
|
|
1891
|
-
}
|
|
1892
|
-
}));
|
|
1893
|
-
this._register(this.files.onDidRemove(modelUri => this._onDidChange.fire([modelUri])));
|
|
1894
|
-
this._register(this.files.onDidChangeReadonly(model => this._onDidChange.fire([model.resource])));
|
|
1895
|
-
this._register(this.files.onDidChangeOrphaned(model => this._onDidChange.fire([model.resource])));
|
|
1896
|
-
}
|
|
1897
|
-
provideDecorations(uri) {
|
|
1898
|
-
const model = this.files.get(uri);
|
|
1899
|
-
if (!model || model.isDisposed()) {
|
|
1900
|
-
return undefined;
|
|
1901
|
-
}
|
|
1902
|
-
const isReadonly = model.isReadonly();
|
|
1903
|
-
const isOrphaned = model.hasState(4 );
|
|
1904
|
-
if (isReadonly && isOrphaned) {
|
|
1905
|
-
return {
|
|
1906
|
-
color: listErrorForeground,
|
|
1907
|
-
letter: Codicon.lockSmall,
|
|
1908
|
-
strikethrough: true,
|
|
1909
|
-
tooltip: ( (localize('readonlyAndDeleted', "Deleted, Read Only"))),
|
|
1910
|
-
};
|
|
1911
|
-
}
|
|
1912
|
-
else if (isReadonly) {
|
|
1913
|
-
return {
|
|
1914
|
-
letter: Codicon.lockSmall,
|
|
1915
|
-
tooltip: ( (localize('readonly', "Read Only"))),
|
|
1916
|
-
};
|
|
1917
|
-
}
|
|
1918
|
-
else if (isOrphaned) {
|
|
1919
|
-
return {
|
|
1920
|
-
color: listErrorForeground,
|
|
1921
|
-
strikethrough: true,
|
|
1922
|
-
tooltip: ( (localize('deleted', "Deleted"))),
|
|
1923
|
-
};
|
|
1924
|
-
}
|
|
1925
|
-
return undefined;
|
|
1926
|
-
}
|
|
1927
|
-
})(this.files));
|
|
1348
|
+
getPreferredDescription() {
|
|
1349
|
+
return this.preferredDescription;
|
|
1928
1350
|
}
|
|
1929
|
-
|
|
1930
|
-
if (
|
|
1931
|
-
|
|
1351
|
+
getEncoding() {
|
|
1352
|
+
if (this.model) {
|
|
1353
|
+
return this.model.getEncoding();
|
|
1932
1354
|
}
|
|
1933
|
-
return this.
|
|
1355
|
+
return this.preferredEncoding;
|
|
1934
1356
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
...options,
|
|
1938
|
-
preferUnbuffered: true
|
|
1939
|
-
});
|
|
1940
|
-
return {
|
|
1941
|
-
...bufferStream,
|
|
1942
|
-
encoding: decoder.detected.encoding || UTF8,
|
|
1943
|
-
value: await consumeStream(decoder.stream, strings => strings.join(''))
|
|
1944
|
-
};
|
|
1357
|
+
getPreferredEncoding() {
|
|
1358
|
+
return this.preferredEncoding;
|
|
1945
1359
|
}
|
|
1946
|
-
async
|
|
1947
|
-
|
|
1948
|
-
return
|
|
1949
|
-
...bufferStream,
|
|
1950
|
-
encoding: decoder.detected.encoding || UTF8,
|
|
1951
|
-
value: await createTextBufferFactoryFromStream(decoder.stream)
|
|
1952
|
-
};
|
|
1360
|
+
async setEncoding(encoding, mode) {
|
|
1361
|
+
this.setPreferredEncoding(encoding);
|
|
1362
|
+
return this.model?.setEncoding(encoding, mode);
|
|
1953
1363
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
value: bufferToStream(content.value)
|
|
1962
|
-
};
|
|
1963
|
-
}
|
|
1964
|
-
else {
|
|
1965
|
-
bufferStream = await this.fileService.readFileStream(resource, options, cts.token);
|
|
1966
|
-
}
|
|
1967
|
-
try {
|
|
1968
|
-
const decoder = await this.doGetDecodedStream(resource, bufferStream.value, options);
|
|
1969
|
-
return [bufferStream, decoder];
|
|
1970
|
-
}
|
|
1971
|
-
catch (error) {
|
|
1972
|
-
cts.dispose(true);
|
|
1973
|
-
if (error.decodeStreamErrorKind === 1 ) {
|
|
1974
|
-
throw new TextFileOperationError(localize('fileBinaryError', "File seems to be binary and cannot be opened as text"), 0 , options);
|
|
1975
|
-
}
|
|
1976
|
-
else {
|
|
1977
|
-
throw error;
|
|
1978
|
-
}
|
|
1364
|
+
setPreferredEncoding(encoding) {
|
|
1365
|
+
this.preferredEncoding = encoding;
|
|
1366
|
+
this.setForceOpenAsText();
|
|
1367
|
+
}
|
|
1368
|
+
getLanguageId() {
|
|
1369
|
+
if (this.model) {
|
|
1370
|
+
return this.model.getLanguageId();
|
|
1979
1371
|
}
|
|
1372
|
+
return this.preferredLanguageId;
|
|
1980
1373
|
}
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
const contents = await this.getEncodedReadable(operation.resource, operation.value);
|
|
1984
|
-
return {
|
|
1985
|
-
resource: operation.resource,
|
|
1986
|
-
contents,
|
|
1987
|
-
overwrite: operation.options?.overwrite
|
|
1988
|
-
};
|
|
1989
|
-
}))));
|
|
1990
|
-
return this.workingCopyFileService.create(operationsWithContents, CancellationToken.None, undoInfo);
|
|
1374
|
+
getPreferredLanguageId() {
|
|
1375
|
+
return this.preferredLanguageId;
|
|
1991
1376
|
}
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
return this.elevatedFileService.writeFileElevated(resource, readable, options);
|
|
1996
|
-
}
|
|
1997
|
-
return this.fileService.writeFile(resource, readable, options);
|
|
1377
|
+
setLanguageId(languageId, source) {
|
|
1378
|
+
this.setPreferredLanguageId(languageId);
|
|
1379
|
+
this.model?.setLanguageId(languageId, source);
|
|
1998
1380
|
}
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
return typeof value === 'undefined'
|
|
2003
|
-
? undefined
|
|
2004
|
-
: toBufferOrReadable(value);
|
|
2005
|
-
}
|
|
2006
|
-
value = value || '';
|
|
2007
|
-
const snapshot = typeof value === 'string' ? stringToSnapshot(value) : value;
|
|
2008
|
-
return toEncodeReadable(snapshot, encoding, { addBOM });
|
|
1381
|
+
setPreferredLanguageId(languageId) {
|
|
1382
|
+
this.preferredLanguageId = languageId;
|
|
1383
|
+
this.setForceOpenAsText();
|
|
2009
1384
|
}
|
|
2010
|
-
|
|
2011
|
-
|
|
1385
|
+
setPreferredContents(contents) {
|
|
1386
|
+
this.preferredContents = contents;
|
|
1387
|
+
this.setForceOpenAsText();
|
|
2012
1388
|
}
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
acceptTextOnly: options?.acceptTextOnly ?? false,
|
|
2016
|
-
guessEncoding: options?.autoGuessEncoding || this.textResourceConfigurationService.getValue(resource, 'files.autoGuessEncoding'),
|
|
2017
|
-
overwriteEncoding: async (detectedEncoding) => {
|
|
2018
|
-
const { encoding } = await this.encoding.getPreferredReadEncoding(resource, options, withNullAsUndefined(detectedEncoding));
|
|
2019
|
-
return encoding;
|
|
2020
|
-
}
|
|
2021
|
-
});
|
|
1389
|
+
setForceOpenAsText() {
|
|
1390
|
+
this.forceOpenAs = 1 ;
|
|
2022
1391
|
}
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
targetUri = await this.fileDialogService.pickFileToSave(await this.suggestSavePath(resource), options?.availableFileSystems);
|
|
2033
|
-
}
|
|
2034
|
-
if (targetUri) {
|
|
2035
|
-
return this.saveAs(resource, targetUri, options);
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
1392
|
+
setForceOpenAsBinary() {
|
|
1393
|
+
this.forceOpenAs = 2 ;
|
|
1394
|
+
}
|
|
1395
|
+
isDirty() {
|
|
1396
|
+
return !!(this.model?.isDirty());
|
|
1397
|
+
}
|
|
1398
|
+
isSaving() {
|
|
1399
|
+
if (this.model?.hasState(0 ) || this.model?.hasState(3 ) || this.model?.hasState(5 )) {
|
|
1400
|
+
return false;
|
|
2038
1401
|
}
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
if (model) {
|
|
2042
|
-
return (await model.save(options)) ? resource : undefined;
|
|
2043
|
-
}
|
|
1402
|
+
if (this.filesConfigurationService.getAutoSaveMode() === 1 ) {
|
|
1403
|
+
return true;
|
|
2044
1404
|
}
|
|
2045
|
-
return
|
|
1405
|
+
return super.isSaving();
|
|
2046
1406
|
}
|
|
2047
|
-
|
|
2048
|
-
if (
|
|
2049
|
-
|
|
1407
|
+
prefersEditorPane(editorPanes) {
|
|
1408
|
+
if (this.forceOpenAs === 2 ) {
|
|
1409
|
+
return editorPanes.find(editorPane => editorPane.typeId === BINARY_FILE_EDITOR_ID);
|
|
2050
1410
|
}
|
|
2051
|
-
|
|
2052
|
-
|
|
1411
|
+
return editorPanes.find(editorPane => editorPane.typeId === TEXT_FILE_EDITOR_ID);
|
|
1412
|
+
}
|
|
1413
|
+
resolve(options) {
|
|
1414
|
+
if (this.forceOpenAs === 2 ) {
|
|
1415
|
+
return this.doResolveAsBinary();
|
|
2053
1416
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
1417
|
+
return this.doResolveAsText(options);
|
|
1418
|
+
}
|
|
1419
|
+
async doResolveAsText(options) {
|
|
1420
|
+
try {
|
|
1421
|
+
const preferredContents = this.preferredContents;
|
|
1422
|
+
this.preferredContents = undefined;
|
|
1423
|
+
await this.textFileService.files.resolve(this.resource, {
|
|
1424
|
+
languageId: this.preferredLanguageId,
|
|
1425
|
+
encoding: this.preferredEncoding,
|
|
1426
|
+
contents: typeof preferredContents === 'string' ? createTextBufferFactory(preferredContents) : undefined,
|
|
1427
|
+
reload: { async: true },
|
|
1428
|
+
allowBinary: this.forceOpenAs === 1 ,
|
|
1429
|
+
reason: 1 ,
|
|
1430
|
+
limits: this.ensureLimits(options)
|
|
1431
|
+
});
|
|
1432
|
+
if (!this.cachedTextFileModelReference) {
|
|
1433
|
+
this.cachedTextFileModelReference = await this.textModelResolverService.createModelReference(this.resource);
|
|
1434
|
+
}
|
|
1435
|
+
const model = this.cachedTextFileModelReference.object;
|
|
1436
|
+
if (this.isDisposed()) {
|
|
1437
|
+
this.disposeModelReference();
|
|
1438
|
+
}
|
|
1439
|
+
return model;
|
|
2056
1440
|
}
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
if (!success) {
|
|
2061
|
-
await this.save(target, options);
|
|
1441
|
+
catch (error) {
|
|
1442
|
+
if (error.textFileOperationResult === 0 ) {
|
|
1443
|
+
return this.doResolveAsBinary();
|
|
2062
1444
|
}
|
|
2063
|
-
|
|
1445
|
+
throw error;
|
|
2064
1446
|
}
|
|
2065
|
-
return this.doSaveAs(source, target, options);
|
|
2066
1447
|
}
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
if (textFileModel?.isResolved()) {
|
|
2071
|
-
success = await this.doSaveAsTextFile(textFileModel, source, target, options);
|
|
2072
|
-
}
|
|
2073
|
-
else if (this.fileService.hasProvider(source)) {
|
|
2074
|
-
await this.fileService.copy(source, target, true);
|
|
2075
|
-
success = true;
|
|
1448
|
+
ensureLimits(options) {
|
|
1449
|
+
if (options?.limits) {
|
|
1450
|
+
return options.limits;
|
|
2076
1451
|
}
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
1452
|
+
const defaultSizeLimit = getLargeFileConfirmationLimit(this.resource);
|
|
1453
|
+
let configuredSizeLimit = undefined;
|
|
1454
|
+
const configuredSizeLimitMb = this.textResourceConfigurationService.getValue(this.resource, 'workbench.editorLargeFileConfirmation');
|
|
1455
|
+
if (typeof configuredSizeLimitMb === 'number') {
|
|
1456
|
+
configuredSizeLimit = configuredSizeLimitMb * ByteSize.MB;
|
|
2082
1457
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
1458
|
+
return {
|
|
1459
|
+
size: Math.max(defaultSizeLimit, configuredSizeLimit ?? defaultSizeLimit)
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
async doResolveAsBinary() {
|
|
1463
|
+
const model = this.instantiationService.createInstance(BinaryEditorModel, this.preferredResource, this.getName());
|
|
1464
|
+
await model.resolve();
|
|
1465
|
+
return model;
|
|
1466
|
+
}
|
|
1467
|
+
isResolved() {
|
|
1468
|
+
return !!this.model;
|
|
1469
|
+
}
|
|
1470
|
+
async rename(group, target) {
|
|
1471
|
+
return {
|
|
1472
|
+
editor: {
|
|
1473
|
+
resource: target,
|
|
1474
|
+
encoding: this.getEncoding(),
|
|
1475
|
+
options: {
|
|
1476
|
+
viewState: findViewStateForEditor(this, group, this.editorService)
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
toUntyped(options) {
|
|
1482
|
+
const untypedInput = {
|
|
1483
|
+
resource: this.preferredResource,
|
|
1484
|
+
forceFile: true,
|
|
1485
|
+
options: {
|
|
1486
|
+
override: this.editorId
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
if (typeof options?.preserveViewState === 'number') {
|
|
1490
|
+
untypedInput.encoding = this.getEncoding();
|
|
1491
|
+
untypedInput.languageId = this.getLanguageId();
|
|
1492
|
+
untypedInput.contents = (() => {
|
|
1493
|
+
const model = this.textFileService.files.get(this.resource);
|
|
1494
|
+
if (model?.isDirty()) {
|
|
1495
|
+
return model.textEditorModel.getValue();
|
|
1496
|
+
}
|
|
1497
|
+
return undefined;
|
|
1498
|
+
})();
|
|
1499
|
+
untypedInput.options = {
|
|
1500
|
+
...untypedInput.options,
|
|
1501
|
+
viewState: findViewStateForEditor(this, options.preserveViewState, this.editorService)
|
|
1502
|
+
};
|
|
2085
1503
|
}
|
|
2086
|
-
|
|
2087
|
-
|
|
1504
|
+
return untypedInput;
|
|
1505
|
+
}
|
|
1506
|
+
matches(otherInput) {
|
|
1507
|
+
if (this === otherInput) {
|
|
1508
|
+
return true;
|
|
2088
1509
|
}
|
|
2089
|
-
|
|
2090
|
-
this.
|
|
1510
|
+
if (otherInput instanceof FileEditorInput) {
|
|
1511
|
+
return isEqual(otherInput.resource, this.resource);
|
|
2091
1512
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
async doSaveAsTextFile(sourceModel, source, target, options) {
|
|
2095
|
-
let sourceModelEncoding = undefined;
|
|
2096
|
-
const sourceModelWithEncodingSupport = sourceModel;
|
|
2097
|
-
if (typeof sourceModelWithEncodingSupport.getEncoding === 'function') {
|
|
2098
|
-
sourceModelEncoding = sourceModelWithEncodingSupport.getEncoding();
|
|
1513
|
+
if (isResourceEditorInput(otherInput)) {
|
|
1514
|
+
return super.matches(otherInput);
|
|
2099
1515
|
}
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
1516
|
+
return false;
|
|
1517
|
+
}
|
|
1518
|
+
dispose() {
|
|
1519
|
+
this.model = undefined;
|
|
1520
|
+
this.disposeModelReference();
|
|
1521
|
+
super.dispose();
|
|
1522
|
+
}
|
|
1523
|
+
disposeModelReference() {
|
|
1524
|
+
dispose(this.cachedTextFileModelReference);
|
|
1525
|
+
this.cachedTextFileModelReference = undefined;
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
FileEditorInput = ( (__decorate([
|
|
1529
|
+
( (__param(7, IInstantiationService))),
|
|
1530
|
+
( (__param(8, ITextFileService))),
|
|
1531
|
+
( (__param(9, ITextModelService))),
|
|
1532
|
+
( (__param(10, ILabelService))),
|
|
1533
|
+
( (__param(11, IFileService))),
|
|
1534
|
+
( (__param(12, IFilesConfigurationService))),
|
|
1535
|
+
( (__param(13, IEditorService))),
|
|
1536
|
+
( (__param(14, IPathService))),
|
|
1537
|
+
( (__param(15, ITextResourceConfigurationService)))
|
|
1538
|
+
], FileEditorInput)));
|
|
1539
|
+
class ExplorerFileNestingTrie {
|
|
1540
|
+
constructor(config) {
|
|
1541
|
+
this.root = ( (new PreTrie()));
|
|
1542
|
+
for (const [parentPattern, childPatterns] of config) {
|
|
1543
|
+
for (const childPattern of childPatterns) {
|
|
1544
|
+
this.root.add(parentPattern, childPattern);
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
toString() {
|
|
1549
|
+
return (
|
|
1550
|
+
(this.root.toString())
|
|
1551
|
+
);
|
|
1552
|
+
}
|
|
1553
|
+
getAttributes(filename, dirname) {
|
|
1554
|
+
const lastDot = filename.lastIndexOf('.');
|
|
1555
|
+
if (lastDot < 1) {
|
|
1556
|
+
return {
|
|
1557
|
+
dirname,
|
|
1558
|
+
basename: filename,
|
|
1559
|
+
extname: ''
|
|
1560
|
+
};
|
|
2104
1561
|
}
|
|
2105
1562
|
else {
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
1563
|
+
return {
|
|
1564
|
+
dirname,
|
|
1565
|
+
basename: filename.substring(0, lastDot),
|
|
1566
|
+
extname: filename.substring(lastDot + 1)
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
nest(files, dirname) {
|
|
1571
|
+
const parentFinder = ( (new PreTrie()));
|
|
1572
|
+
for (const potentialParent of files) {
|
|
1573
|
+
const attributes = this.getAttributes(potentialParent, dirname);
|
|
1574
|
+
const children = this.root.get(potentialParent, attributes);
|
|
1575
|
+
for (const child of children) {
|
|
1576
|
+
parentFinder.add(child, potentialParent);
|
|
2109
1577
|
}
|
|
2110
|
-
|
|
2111
|
-
|
|
1578
|
+
}
|
|
1579
|
+
const findAllRootAncestors = (file, seen = ( (new Set()))) => {
|
|
1580
|
+
if (seen.has(file)) {
|
|
1581
|
+
return [];
|
|
2112
1582
|
}
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
1583
|
+
seen.add(file);
|
|
1584
|
+
const attributes = this.getAttributes(file, dirname);
|
|
1585
|
+
const ancestors = parentFinder.get(file, attributes);
|
|
1586
|
+
if (ancestors.length === 0) {
|
|
1587
|
+
return [file];
|
|
1588
|
+
}
|
|
1589
|
+
if (ancestors.length === 1 && ancestors[0] === file) {
|
|
1590
|
+
return [file];
|
|
1591
|
+
}
|
|
1592
|
+
return ancestors.flatMap(a => findAllRootAncestors(a, seen));
|
|
1593
|
+
};
|
|
1594
|
+
const result = ( (new Map()));
|
|
1595
|
+
for (const file of files) {
|
|
1596
|
+
let ancestors = findAllRootAncestors(file);
|
|
1597
|
+
if (ancestors.length === 0) {
|
|
1598
|
+
ancestors = [file];
|
|
1599
|
+
}
|
|
1600
|
+
for (const ancestor of ancestors) {
|
|
1601
|
+
let existing = result.get(ancestor);
|
|
1602
|
+
if (!existing) {
|
|
1603
|
+
result.set(ancestor, existing = ( (new Set())));
|
|
1604
|
+
}
|
|
1605
|
+
if (file !== ancestor) {
|
|
1606
|
+
existing.add(file);
|
|
2120
1607
|
}
|
|
2121
|
-
throw error;
|
|
2122
1608
|
}
|
|
2123
1609
|
}
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
1610
|
+
return result;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
class PreTrie {
|
|
1614
|
+
constructor() {
|
|
1615
|
+
this.value = ( (new SufTrie()));
|
|
1616
|
+
this.map = ( (new Map()));
|
|
1617
|
+
}
|
|
1618
|
+
add(key, value) {
|
|
1619
|
+
if (key === '') {
|
|
1620
|
+
this.value.add(key, value);
|
|
1621
|
+
}
|
|
1622
|
+
else if (key[0] === '*') {
|
|
1623
|
+
this.value.add(key, value);
|
|
2127
1624
|
}
|
|
2128
1625
|
else {
|
|
2129
|
-
|
|
1626
|
+
const head = key[0];
|
|
1627
|
+
const rest = key.slice(1);
|
|
1628
|
+
let existing = this.map.get(head);
|
|
1629
|
+
if (!existing) {
|
|
1630
|
+
this.map.set(head, existing = ( (new PreTrie())));
|
|
1631
|
+
}
|
|
1632
|
+
existing.add(rest, value);
|
|
2130
1633
|
}
|
|
2131
|
-
|
|
2132
|
-
|
|
1634
|
+
}
|
|
1635
|
+
get(key, attributes) {
|
|
1636
|
+
const results = [];
|
|
1637
|
+
results.push(...this.value.get(key, attributes));
|
|
1638
|
+
const head = key[0];
|
|
1639
|
+
const rest = key.slice(1);
|
|
1640
|
+
const existing = this.map.get(head);
|
|
1641
|
+
if (existing) {
|
|
1642
|
+
results.push(...existing.get(rest, attributes));
|
|
2133
1643
|
}
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
1644
|
+
return results;
|
|
1645
|
+
}
|
|
1646
|
+
toString(indentation = '') {
|
|
1647
|
+
const lines = [];
|
|
1648
|
+
if (this.value.hasItems) {
|
|
1649
|
+
lines.push('* => \n' + ( (this.value.toString(indentation + ' '))));
|
|
1650
|
+
}
|
|
1651
|
+
return ( (lines.map(l => indentation + l))).join('\n');
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
class SufTrie {
|
|
1655
|
+
constructor() {
|
|
1656
|
+
this.star = [];
|
|
1657
|
+
this.epsilon = [];
|
|
1658
|
+
this.map = ( (new Map()));
|
|
1659
|
+
this.hasItems = false;
|
|
1660
|
+
}
|
|
1661
|
+
add(key, value) {
|
|
1662
|
+
this.hasItems = true;
|
|
1663
|
+
if (key === '*') {
|
|
1664
|
+
this.star.push(( (new SubstitutionString(value))));
|
|
1665
|
+
}
|
|
1666
|
+
else if (key === '') {
|
|
1667
|
+
this.epsilon.push(( (new SubstitutionString(value))));
|
|
2139
1668
|
}
|
|
2140
1669
|
else {
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
const sourceLanguageId = sourceTextModel.getLanguageId();
|
|
2151
|
-
const targetLanguageId = targetTextModel.getLanguageId();
|
|
2152
|
-
if (sourceLanguageId !== PLAINTEXT_LANGUAGE_ID && targetLanguageId === PLAINTEXT_LANGUAGE_ID) {
|
|
2153
|
-
targetTextModel.setMode(sourceLanguageId);
|
|
2154
|
-
}
|
|
2155
|
-
const sourceTransientProperties = this.codeEditorService.getTransientModelProperties(sourceTextModel);
|
|
2156
|
-
if (sourceTransientProperties) {
|
|
2157
|
-
for (const [key, value] of sourceTransientProperties) {
|
|
2158
|
-
this.codeEditorService.setTransientModelProperty(targetTextModel, key, value);
|
|
1670
|
+
const tail = key[key.length - 1];
|
|
1671
|
+
const rest = key.slice(0, key.length - 1);
|
|
1672
|
+
if (tail === '*') {
|
|
1673
|
+
throw Error('Unexpected star in SufTrie key: ' + key);
|
|
1674
|
+
}
|
|
1675
|
+
else {
|
|
1676
|
+
let existing = this.map.get(tail);
|
|
1677
|
+
if (!existing) {
|
|
1678
|
+
this.map.set(tail, existing = ( (new SufTrie())));
|
|
2159
1679
|
}
|
|
1680
|
+
existing.add(rest, value);
|
|
2160
1681
|
}
|
|
2161
1682
|
}
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
1683
|
+
}
|
|
1684
|
+
get(key, attributes) {
|
|
1685
|
+
const results = [];
|
|
1686
|
+
if (key === '') {
|
|
1687
|
+
results.push(...( (this.epsilon.map(ss => ss.substitute(attributes)))));
|
|
1688
|
+
}
|
|
1689
|
+
if (this.star.length) {
|
|
1690
|
+
results.push(...( (this.star.map(ss => ss.substitute(attributes, key)))));
|
|
1691
|
+
}
|
|
1692
|
+
const tail = key[key.length - 1];
|
|
1693
|
+
const rest = key.slice(0, key.length - 1);
|
|
1694
|
+
const existing = this.map.get(tail);
|
|
1695
|
+
if (existing) {
|
|
1696
|
+
results.push(...existing.get(rest, attributes));
|
|
2167
1697
|
}
|
|
2168
|
-
return
|
|
1698
|
+
return results;
|
|
2169
1699
|
}
|
|
2170
|
-
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
1700
|
+
toString(indentation = '') {
|
|
1701
|
+
const lines = [];
|
|
1702
|
+
if (this.star.length) {
|
|
1703
|
+
lines.push('* => ' + this.star.join('; '));
|
|
1704
|
+
}
|
|
1705
|
+
if (this.epsilon.length) {
|
|
1706
|
+
lines.push('ε => ' + this.epsilon.join('; '));
|
|
1707
|
+
}
|
|
1708
|
+
return ( (lines.map(l => indentation + l))).join('\n');
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
const substitutionStringTokenizer = /\$[({](capture|basename|dirname|extname)[)}]/g;
|
|
1712
|
+
class SubstitutionString {
|
|
1713
|
+
constructor(pattern) {
|
|
1714
|
+
this.tokens = [];
|
|
1715
|
+
substitutionStringTokenizer.lastIndex = 0;
|
|
1716
|
+
let token;
|
|
1717
|
+
let lastIndex = 0;
|
|
1718
|
+
while (token = substitutionStringTokenizer.exec(pattern)) {
|
|
1719
|
+
const prefix = pattern.slice(lastIndex, token.index);
|
|
1720
|
+
this.tokens.push(prefix);
|
|
1721
|
+
const type = token[1];
|
|
1722
|
+
switch (type) {
|
|
1723
|
+
case "basename" :
|
|
1724
|
+
case "dirname" :
|
|
1725
|
+
case "extname" :
|
|
1726
|
+
case "capture" :
|
|
1727
|
+
this.tokens.push({ capture: type });
|
|
1728
|
+
break;
|
|
1729
|
+
default: throw Error('unknown substitution type: ' + type);
|
|
1730
|
+
}
|
|
1731
|
+
lastIndex = token.index + token[0].length;
|
|
1732
|
+
}
|
|
1733
|
+
if (lastIndex !== pattern.length) {
|
|
1734
|
+
const suffix = pattern.slice(lastIndex, pattern.length);
|
|
1735
|
+
this.tokens.push(suffix);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
substitute(attributes, capture) {
|
|
1739
|
+
return ( (this.tokens.map(t => {
|
|
1740
|
+
if (typeof t === 'string') {
|
|
1741
|
+
return t;
|
|
1742
|
+
}
|
|
1743
|
+
switch (t.capture) {
|
|
1744
|
+
case "basename" : return attributes.basename;
|
|
1745
|
+
case "dirname" : return attributes.dirname;
|
|
1746
|
+
case "extname" : return attributes.extname;
|
|
1747
|
+
case "capture" : return capture || '';
|
|
1748
|
+
}
|
|
1749
|
+
}))).join('');
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
class ExplorerModel {
|
|
1753
|
+
constructor(contextService, uriIdentityService, fileService, configService) {
|
|
1754
|
+
this.contextService = contextService;
|
|
1755
|
+
this.uriIdentityService = uriIdentityService;
|
|
1756
|
+
this._onDidChangeRoots = ( (new Emitter()));
|
|
1757
|
+
const setRoots = () => this._roots = ( (this.contextService.getWorkspace().folders
|
|
1758
|
+
.map(folder => ( (new ExplorerItem(
|
|
1759
|
+
folder.uri,
|
|
1760
|
+
fileService,
|
|
1761
|
+
configService,
|
|
1762
|
+
undefined,
|
|
1763
|
+
true,
|
|
1764
|
+
false,
|
|
1765
|
+
false,
|
|
1766
|
+
folder.name
|
|
1767
|
+
))))));
|
|
1768
|
+
setRoots();
|
|
1769
|
+
this._listener = this.contextService.onDidChangeWorkspaceFolders(() => {
|
|
1770
|
+
setRoots();
|
|
1771
|
+
this._onDidChangeRoots.fire();
|
|
2188
1772
|
});
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
1773
|
+
}
|
|
1774
|
+
get roots() {
|
|
1775
|
+
return this._roots;
|
|
1776
|
+
}
|
|
1777
|
+
get onDidChangeRoots() {
|
|
1778
|
+
return this._onDidChangeRoots.event;
|
|
1779
|
+
}
|
|
1780
|
+
findAll(resource) {
|
|
1781
|
+
return coalesce(( (this.roots.map(root => root.find(resource)))));
|
|
1782
|
+
}
|
|
1783
|
+
findClosest(resource) {
|
|
1784
|
+
const folder = this.contextService.getWorkspaceFolder(resource);
|
|
1785
|
+
if (folder) {
|
|
1786
|
+
const root = this.roots.find(r => this.uriIdentityService.extUri.isEqual(r.resource, folder.uri));
|
|
1787
|
+
if (root) {
|
|
1788
|
+
return root.find(resource);
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
return null;
|
|
1792
|
+
}
|
|
1793
|
+
dispose() {
|
|
1794
|
+
dispose(this._listener);
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
class ExplorerItem {
|
|
1798
|
+
constructor(resource, fileService, configService, _parent, _isDirectory, _isSymbolicLink, _readonly, _name = basenameOrAuthority(resource), _mtime, _unknown = false) {
|
|
1799
|
+
this.resource = resource;
|
|
1800
|
+
this.fileService = fileService;
|
|
1801
|
+
this.configService = configService;
|
|
1802
|
+
this._parent = _parent;
|
|
1803
|
+
this._isDirectory = _isDirectory;
|
|
1804
|
+
this._isSymbolicLink = _isSymbolicLink;
|
|
1805
|
+
this._readonly = _readonly;
|
|
1806
|
+
this._name = _name;
|
|
1807
|
+
this._mtime = _mtime;
|
|
1808
|
+
this._unknown = _unknown;
|
|
1809
|
+
this.error = undefined;
|
|
1810
|
+
this._isExcluded = false;
|
|
1811
|
+
this._isDirectoryResolved = false;
|
|
1812
|
+
}
|
|
1813
|
+
get isExcluded() {
|
|
1814
|
+
if (this._isExcluded) {
|
|
1815
|
+
return true;
|
|
1816
|
+
}
|
|
1817
|
+
if (!this._parent) {
|
|
1818
|
+
return false;
|
|
1819
|
+
}
|
|
1820
|
+
return this._parent.isExcluded;
|
|
1821
|
+
}
|
|
1822
|
+
set isExcluded(value) {
|
|
1823
|
+
this._isExcluded = value;
|
|
1824
|
+
}
|
|
1825
|
+
hasChildren(filter) {
|
|
1826
|
+
if (this.hasNests) {
|
|
1827
|
+
return this.nestedChildren?.some(c => filter(c)) ?? false;
|
|
1828
|
+
}
|
|
1829
|
+
else {
|
|
1830
|
+
return this.isDirectory;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
get hasNests() {
|
|
1834
|
+
return !!(this.nestedChildren?.length);
|
|
1835
|
+
}
|
|
1836
|
+
get isDirectoryResolved() {
|
|
1837
|
+
return this._isDirectoryResolved;
|
|
1838
|
+
}
|
|
1839
|
+
get isSymbolicLink() {
|
|
1840
|
+
return !!this._isSymbolicLink;
|
|
1841
|
+
}
|
|
1842
|
+
get isDirectory() {
|
|
1843
|
+
return !!this._isDirectory;
|
|
1844
|
+
}
|
|
1845
|
+
get isReadonly() {
|
|
1846
|
+
return this._readonly || this.fileService.hasCapability(this.resource, 2048 );
|
|
1847
|
+
}
|
|
1848
|
+
get mtime() {
|
|
1849
|
+
return this._mtime;
|
|
1850
|
+
}
|
|
1851
|
+
get name() {
|
|
1852
|
+
return this._name;
|
|
1853
|
+
}
|
|
1854
|
+
get isUnknown() {
|
|
1855
|
+
return this._unknown;
|
|
1856
|
+
}
|
|
1857
|
+
get parent() {
|
|
1858
|
+
return this._parent;
|
|
1859
|
+
}
|
|
1860
|
+
get root() {
|
|
1861
|
+
if (!this._parent) {
|
|
1862
|
+
return this;
|
|
1863
|
+
}
|
|
1864
|
+
return this._parent.root;
|
|
1865
|
+
}
|
|
1866
|
+
get children() {
|
|
1867
|
+
return (
|
|
1868
|
+
(new Map())
|
|
1869
|
+
);
|
|
1870
|
+
}
|
|
1871
|
+
updateName(value) {
|
|
1872
|
+
this._parent?.removeChild(this);
|
|
1873
|
+
this._name = value;
|
|
1874
|
+
this._parent?.addChild(this);
|
|
1875
|
+
}
|
|
1876
|
+
getId() {
|
|
1877
|
+
return ( (this.root.resource.toString())) + '::' + ( (this.resource.toString()));
|
|
1878
|
+
}
|
|
1879
|
+
toString() {
|
|
1880
|
+
return `ExplorerItem: ${this.name}`;
|
|
1881
|
+
}
|
|
1882
|
+
get isRoot() {
|
|
1883
|
+
return this === this.root;
|
|
1884
|
+
}
|
|
1885
|
+
static create(fileService, configService, raw, parent, resolveTo) {
|
|
1886
|
+
const stat = ( (new ExplorerItem(
|
|
1887
|
+
raw.resource,
|
|
1888
|
+
fileService,
|
|
1889
|
+
configService,
|
|
1890
|
+
parent,
|
|
1891
|
+
raw.isDirectory,
|
|
1892
|
+
raw.isSymbolicLink,
|
|
1893
|
+
raw.readonly,
|
|
1894
|
+
raw.name,
|
|
1895
|
+
raw.mtime,
|
|
1896
|
+
!raw.isFile && !raw.isDirectory
|
|
1897
|
+
)));
|
|
1898
|
+
if (stat.isDirectory) {
|
|
1899
|
+
stat._isDirectoryResolved = !!raw.children || (!!resolveTo && resolveTo.some((r) => {
|
|
1900
|
+
return isEqualOrParent(r, stat.resource);
|
|
1901
|
+
}));
|
|
1902
|
+
if (raw.children) {
|
|
1903
|
+
for (let i = 0, len = raw.children.length; i < len; i++) {
|
|
1904
|
+
const child = ExplorerItem.create(fileService, configService, raw.children[i], stat, resolveTo);
|
|
1905
|
+
stat.addChild(child);
|
|
2203
1906
|
}
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
return stat;
|
|
1910
|
+
}
|
|
1911
|
+
static mergeLocalWithDisk(disk, local) {
|
|
1912
|
+
if (( (disk.resource.toString())) !== ( (local.resource.toString()))) {
|
|
1913
|
+
return;
|
|
1914
|
+
}
|
|
1915
|
+
const mergingDirectories = disk.isDirectory || local.isDirectory;
|
|
1916
|
+
if (mergingDirectories && local._isDirectoryResolved && !disk._isDirectoryResolved) {
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
local.resource = disk.resource;
|
|
1920
|
+
if (!local.isRoot) {
|
|
1921
|
+
local.updateName(disk.name);
|
|
1922
|
+
}
|
|
1923
|
+
local._isDirectory = disk.isDirectory;
|
|
1924
|
+
local._mtime = disk.mtime;
|
|
1925
|
+
local._isDirectoryResolved = disk._isDirectoryResolved;
|
|
1926
|
+
local._isSymbolicLink = disk.isSymbolicLink;
|
|
1927
|
+
local.error = disk.error;
|
|
1928
|
+
if (mergingDirectories && disk._isDirectoryResolved) {
|
|
1929
|
+
const oldLocalChildren = ( (new ResourceMap()));
|
|
1930
|
+
local.children.forEach(child => {
|
|
1931
|
+
oldLocalChildren.set(child.resource, child);
|
|
1932
|
+
});
|
|
1933
|
+
local.children.clear();
|
|
1934
|
+
disk.children.forEach(diskChild => {
|
|
1935
|
+
const formerLocalChild = oldLocalChildren.get(diskChild.resource);
|
|
1936
|
+
if (formerLocalChild) {
|
|
1937
|
+
ExplorerItem.mergeLocalWithDisk(diskChild, formerLocalChild);
|
|
1938
|
+
local.addChild(formerLocalChild);
|
|
1939
|
+
oldLocalChildren.delete(diskChild.resource);
|
|
2207
1940
|
}
|
|
2208
1941
|
else {
|
|
2209
|
-
|
|
2210
|
-
}
|
|
2211
|
-
const languageId = model.getLanguageId();
|
|
2212
|
-
if (languageId && languageId !== PLAINTEXT_LANGUAGE_ID) {
|
|
2213
|
-
suggestedFilename = this.suggestFilename(languageId, nameCandidate);
|
|
1942
|
+
local.addChild(diskChild);
|
|
2214
1943
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
1944
|
+
});
|
|
1945
|
+
oldLocalChildren.forEach(oldChild => {
|
|
1946
|
+
if (oldChild instanceof NewExplorerItem) {
|
|
1947
|
+
local.addChild(oldChild);
|
|
2217
1948
|
}
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
if (!suggestedFilename) {
|
|
2221
|
-
suggestedFilename = basename(resource);
|
|
1949
|
+
});
|
|
2222
1950
|
}
|
|
2223
|
-
return joinPath(defaultFilePath, suggestedFilename);
|
|
2224
1951
|
}
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
1952
|
+
addChild(child) {
|
|
1953
|
+
child._parent = this;
|
|
1954
|
+
child.updateResource(false);
|
|
1955
|
+
this.children.set(this.getPlatformAwareName(child.name), child);
|
|
1956
|
+
}
|
|
1957
|
+
getChild(name) {
|
|
1958
|
+
return this.children.get(this.getPlatformAwareName(name));
|
|
1959
|
+
}
|
|
1960
|
+
fetchChildren(sortOrder) {
|
|
1961
|
+
const nestingConfig = this.configService.getValue({ resource: this.root.resource }).explorer.fileNesting;
|
|
1962
|
+
if (nestingConfig.enabled && this.nestedChildren) {
|
|
1963
|
+
return this.nestedChildren;
|
|
2234
1964
|
}
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
1965
|
+
return (async () => {
|
|
1966
|
+
if (!this._isDirectoryResolved) {
|
|
1967
|
+
const resolveMetadata = sortOrder === "modified" ;
|
|
1968
|
+
this.error = undefined;
|
|
1969
|
+
try {
|
|
1970
|
+
const stat = await this.fileService.resolve(this.resource, { resolveSingleChildDescendants: true, resolveMetadata });
|
|
1971
|
+
const resolved = ExplorerItem.create(this.fileService, this.configService, stat, this);
|
|
1972
|
+
ExplorerItem.mergeLocalWithDisk(resolved, this);
|
|
1973
|
+
}
|
|
1974
|
+
catch (e) {
|
|
1975
|
+
this.error = e;
|
|
1976
|
+
throw e;
|
|
1977
|
+
}
|
|
1978
|
+
this._isDirectoryResolved = true;
|
|
1979
|
+
}
|
|
1980
|
+
const items = [];
|
|
1981
|
+
if (nestingConfig.enabled) {
|
|
1982
|
+
const fileChildren = [];
|
|
1983
|
+
const dirChildren = [];
|
|
1984
|
+
for (const child of this.children.entries()) {
|
|
1985
|
+
child[1].nestedParent = undefined;
|
|
1986
|
+
if (child[1].isDirectory) {
|
|
1987
|
+
dirChildren.push(child);
|
|
1988
|
+
}
|
|
1989
|
+
else {
|
|
1990
|
+
fileChildren.push(child);
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
const nested = this.fileNester.nest(( (fileChildren.map(([name]) => name))), this.getPlatformAwareName(this.name));
|
|
1994
|
+
for (const [fileEntryName, fileEntryItem] of fileChildren) {
|
|
1995
|
+
const nestedItems = nested.get(fileEntryName);
|
|
1996
|
+
if (nestedItems !== undefined) {
|
|
1997
|
+
fileEntryItem.nestedChildren = [];
|
|
1998
|
+
for (const name of ( (nestedItems.keys()))) {
|
|
1999
|
+
const child = assertIsDefined(this.children.get(name));
|
|
2000
|
+
fileEntryItem.nestedChildren.push(child);
|
|
2001
|
+
child.nestedParent = fileEntryItem;
|
|
2002
|
+
}
|
|
2003
|
+
items.push(fileEntryItem);
|
|
2004
|
+
}
|
|
2005
|
+
else {
|
|
2006
|
+
fileEntryItem.nestedChildren = undefined;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
for (const [_, dirEntryItem] of ( (dirChildren.values()))) {
|
|
2010
|
+
items.push(dirEntryItem);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
else {
|
|
2014
|
+
this.children.forEach(child => {
|
|
2015
|
+
items.push(child);
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
return items;
|
|
2019
|
+
})();
|
|
2020
|
+
}
|
|
2021
|
+
get fileNester() {
|
|
2022
|
+
if (!this.root._fileNester) {
|
|
2023
|
+
const nestingConfig = this.configService.getValue({ resource: this.root.resource }).explorer.fileNesting;
|
|
2024
|
+
const patterns = ( (Object.entries(nestingConfig.patterns)
|
|
2025
|
+
.filter(entry => typeof (entry[0]) === 'string' && typeof (entry[1]) === 'string' && entry[0] && entry[1])
|
|
2026
|
+
.map(([parentPattern, childrenPatterns]) => [
|
|
2027
|
+
this.getPlatformAwareName(parentPattern.trim()),
|
|
2028
|
+
( (childrenPatterns.split(',').map(p => this.getPlatformAwareName(p.trim().replace(/\u200b/g, '')))))
|
|
2029
|
+
])));
|
|
2030
|
+
this.root._fileNester = ( (new ExplorerFileNestingTrie(patterns)));
|
|
2031
|
+
}
|
|
2032
|
+
return this.root._fileNester;
|
|
2033
|
+
}
|
|
2034
|
+
removeChild(child) {
|
|
2035
|
+
this.nestedChildren = undefined;
|
|
2036
|
+
this.children.delete(this.getPlatformAwareName(child.name));
|
|
2037
|
+
}
|
|
2038
|
+
forgetChildren() {
|
|
2039
|
+
this.children.clear();
|
|
2040
|
+
this.nestedChildren = undefined;
|
|
2041
|
+
this._isDirectoryResolved = false;
|
|
2042
|
+
this._fileNester = undefined;
|
|
2043
|
+
}
|
|
2044
|
+
getPlatformAwareName(name) {
|
|
2045
|
+
return this.fileService.hasCapability(this.resource, 1024 ) ? name : name.toLowerCase();
|
|
2046
|
+
}
|
|
2047
|
+
move(newParent) {
|
|
2048
|
+
this.nestedParent?.removeChild(this);
|
|
2049
|
+
this._parent?.removeChild(this);
|
|
2050
|
+
newParent.removeChild(this);
|
|
2051
|
+
newParent.addChild(this);
|
|
2052
|
+
this.updateResource(true);
|
|
2053
|
+
}
|
|
2054
|
+
updateResource(recursive) {
|
|
2055
|
+
if (this._parent) {
|
|
2056
|
+
this.resource = joinPath(this._parent.resource, this.name);
|
|
2057
|
+
}
|
|
2058
|
+
if (recursive) {
|
|
2059
|
+
if (this.isDirectory) {
|
|
2060
|
+
this.children.forEach(child => {
|
|
2061
|
+
child.updateResource(true);
|
|
2062
|
+
});
|
|
2239
2063
|
}
|
|
2240
|
-
return `${untitledName}${primaryExtension}`;
|
|
2241
2064
|
}
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2065
|
+
}
|
|
2066
|
+
rename(renamedStat) {
|
|
2067
|
+
this.updateName(renamedStat.name);
|
|
2068
|
+
this._mtime = renamedStat.mtime;
|
|
2069
|
+
this.updateResource(true);
|
|
2070
|
+
}
|
|
2071
|
+
find(resource) {
|
|
2072
|
+
const ignoreCase = !this.fileService.hasCapability(resource, 1024 );
|
|
2073
|
+
if (resource && this.resource.scheme === resource.scheme && equalsIgnoreCase(this.resource.authority, resource.authority) &&
|
|
2074
|
+
(ignoreCase ? startsWithIgnoreCase(resource.path, this.resource.path) : resource.path.startsWith(this.resource.path))) {
|
|
2075
|
+
return this.findByPath(rtrim(resource.path, posix.sep), this.resource.path.length, ignoreCase);
|
|
2245
2076
|
}
|
|
2246
|
-
return
|
|
2077
|
+
return null;
|
|
2247
2078
|
}
|
|
2248
|
-
|
|
2249
|
-
if (resource.
|
|
2250
|
-
|
|
2251
|
-
if (model) {
|
|
2252
|
-
return model.revert(options);
|
|
2253
|
-
}
|
|
2079
|
+
findByPath(path, index, ignoreCase) {
|
|
2080
|
+
if (isEqual$1(rtrim(this.resource.path, posix.sep), path, ignoreCase)) {
|
|
2081
|
+
return this;
|
|
2254
2082
|
}
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2083
|
+
if (this.isDirectory) {
|
|
2084
|
+
while (index < path.length && path[index] === posix.sep) {
|
|
2085
|
+
index++;
|
|
2086
|
+
}
|
|
2087
|
+
let indexOfNextSep = path.indexOf(posix.sep, index);
|
|
2088
|
+
if (indexOfNextSep === -1) {
|
|
2089
|
+
indexOfNextSep = path.length;
|
|
2090
|
+
}
|
|
2091
|
+
const name = path.substring(index, indexOfNextSep);
|
|
2092
|
+
const child = this.children.get(this.getPlatformAwareName(name));
|
|
2093
|
+
if (child) {
|
|
2094
|
+
return child.findByPath(path, indexOfNextSep, ignoreCase);
|
|
2259
2095
|
}
|
|
2260
2096
|
}
|
|
2097
|
+
return null;
|
|
2261
2098
|
}
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2099
|
+
}
|
|
2100
|
+
ExplorerItem.__decorator = ( (__decorate([
|
|
2101
|
+
memoize
|
|
2102
|
+
], ExplorerItem.prototype, "children", null)));
|
|
2103
|
+
class NewExplorerItem extends ExplorerItem {
|
|
2104
|
+
constructor(fileService, configService, parent, isDirectory) {
|
|
2105
|
+
super(URI.file(''), fileService, configService, parent, isDirectory);
|
|
2106
|
+
this._isDirectoryResolved = true;
|
|
2268
2107
|
}
|
|
2269
|
-
}
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
( (__param(0, IFileService))),
|
|
2274
|
-
( (__param(1, IUntitledTextEditorService))),
|
|
2275
|
-
( (__param(2, ILifecycleService))),
|
|
2276
|
-
( (__param(3, IInstantiationService))),
|
|
2277
|
-
( (__param(4, IModelService))),
|
|
2278
|
-
( (__param(5, IWorkbenchEnvironmentService))),
|
|
2279
|
-
( (__param(6, IDialogService))),
|
|
2280
|
-
( (__param(7, IFileDialogService))),
|
|
2281
|
-
( (__param(8, ITextResourceConfigurationService))),
|
|
2282
|
-
( (__param(9, IFilesConfigurationService))),
|
|
2283
|
-
( (__param(10, ICodeEditorService))),
|
|
2284
|
-
( (__param(11, IPathService))),
|
|
2285
|
-
( (__param(12, IWorkingCopyFileService))),
|
|
2286
|
-
( (__param(13, IUriIdentityService))),
|
|
2287
|
-
( (__param(14, ILanguageService))),
|
|
2288
|
-
( (__param(15, ILogService))),
|
|
2289
|
-
( (__param(16, IElevatedFileService))),
|
|
2290
|
-
( (__param(17, IDecorationsService)))
|
|
2291
|
-
], AbstractTextFileService)));
|
|
2292
|
-
let EncodingOracle = class EncodingOracle extends Disposable {
|
|
2293
|
-
get encodingOverrides() { return this._encodingOverrides; }
|
|
2294
|
-
set encodingOverrides(value) { this._encodingOverrides = value; }
|
|
2295
|
-
constructor(textResourceConfigurationService, environmentService, contextService, uriIdentityService) {
|
|
2108
|
+
}
|
|
2109
|
+
const IExplorerService = ( (createDecorator('explorerService')));
|
|
2110
|
+
let ResourceGlobMatcher = class ResourceGlobMatcher extends Disposable {
|
|
2111
|
+
constructor(globFn, shouldUpdate, contextService, configurationService) {
|
|
2296
2112
|
super();
|
|
2297
|
-
this.
|
|
2298
|
-
this.
|
|
2113
|
+
this.globFn = globFn;
|
|
2114
|
+
this.shouldUpdate = shouldUpdate;
|
|
2299
2115
|
this.contextService = contextService;
|
|
2300
|
-
this.
|
|
2301
|
-
this.
|
|
2116
|
+
this.configurationService = configurationService;
|
|
2117
|
+
this._onExpressionChange = this._register(( (new Emitter())));
|
|
2118
|
+
this.onExpressionChange = this._onExpressionChange.event;
|
|
2119
|
+
this.mapRootToParsedExpression = ( (new Map()));
|
|
2120
|
+
this.mapRootToExpressionConfig = ( (new Map()));
|
|
2121
|
+
this.updateExcludes(false);
|
|
2302
2122
|
this.registerListeners();
|
|
2303
2123
|
}
|
|
2304
2124
|
registerListeners() {
|
|
2305
|
-
this._register(this.
|
|
2125
|
+
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
|
2126
|
+
if (this.shouldUpdate(e)) {
|
|
2127
|
+
this.updateExcludes(true);
|
|
2128
|
+
}
|
|
2129
|
+
}));
|
|
2130
|
+
this._register(this.contextService.onDidChangeWorkspaceFolders(() => this.updateExcludes(true)));
|
|
2306
2131
|
}
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
defaultEncodingOverrides.push({ parent: this.environmentService.userRoamingDataHome, encoding: UTF8 });
|
|
2310
|
-
defaultEncodingOverrides.push({ extension: WORKSPACE_EXTENSION, encoding: UTF8 });
|
|
2311
|
-
defaultEncodingOverrides.push({ parent: this.environmentService.untitledWorkspacesHome, encoding: UTF8 });
|
|
2132
|
+
updateExcludes(fromEvent) {
|
|
2133
|
+
let changed = false;
|
|
2312
2134
|
this.contextService.getWorkspace().folders.forEach(folder => {
|
|
2313
|
-
|
|
2135
|
+
const rootExcludes = this.globFn(folder.uri);
|
|
2136
|
+
if (!this.mapRootToExpressionConfig.has(( (folder.uri.toString()))) || !equals(this.mapRootToExpressionConfig.get(( (folder.uri.toString()))), rootExcludes)) {
|
|
2137
|
+
changed = true;
|
|
2138
|
+
this.mapRootToParsedExpression.set(( (folder.uri.toString())), parse(rootExcludes));
|
|
2139
|
+
this.mapRootToExpressionConfig.set(( (folder.uri.toString())), deepClone(rootExcludes));
|
|
2140
|
+
}
|
|
2141
|
+
});
|
|
2142
|
+
this.mapRootToExpressionConfig.forEach((value, root) => {
|
|
2143
|
+
if (root === ResourceGlobMatcher.NO_ROOT) {
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
if (root && !this.contextService.getWorkspaceFolder(( (URI.parse(root))))) {
|
|
2147
|
+
this.mapRootToParsedExpression.delete(root);
|
|
2148
|
+
this.mapRootToExpressionConfig.delete(root);
|
|
2149
|
+
changed = true;
|
|
2150
|
+
}
|
|
2314
2151
|
});
|
|
2315
|
-
|
|
2152
|
+
const globalExcludes = this.globFn();
|
|
2153
|
+
if (!this.mapRootToExpressionConfig.has(ResourceGlobMatcher.NO_ROOT) || !equals(this.mapRootToExpressionConfig.get(ResourceGlobMatcher.NO_ROOT), globalExcludes)) {
|
|
2154
|
+
changed = true;
|
|
2155
|
+
this.mapRootToParsedExpression.set(ResourceGlobMatcher.NO_ROOT, parse(globalExcludes));
|
|
2156
|
+
this.mapRootToExpressionConfig.set(ResourceGlobMatcher.NO_ROOT, deepClone(globalExcludes));
|
|
2157
|
+
}
|
|
2158
|
+
if (fromEvent && changed) {
|
|
2159
|
+
this._onExpressionChange.fire();
|
|
2160
|
+
}
|
|
2316
2161
|
}
|
|
2317
|
-
|
|
2318
|
-
const
|
|
2319
|
-
|
|
2162
|
+
matches(resource, hasSibling) {
|
|
2163
|
+
const folder = this.contextService.getWorkspaceFolder(resource);
|
|
2164
|
+
let expressionForRoot;
|
|
2165
|
+
if (folder && this.mapRootToParsedExpression.has(( (folder.uri.toString())))) {
|
|
2166
|
+
expressionForRoot = this.mapRootToParsedExpression.get(( (folder.uri.toString())));
|
|
2167
|
+
}
|
|
2168
|
+
else {
|
|
2169
|
+
expressionForRoot = this.mapRootToParsedExpression.get(ResourceGlobMatcher.NO_ROOT);
|
|
2170
|
+
}
|
|
2171
|
+
let resourcePathToMatch;
|
|
2172
|
+
if (folder) {
|
|
2173
|
+
resourcePathToMatch = relativePath(folder.uri, resource);
|
|
2174
|
+
}
|
|
2175
|
+
else {
|
|
2176
|
+
resourcePathToMatch = resource.fsPath;
|
|
2177
|
+
}
|
|
2178
|
+
return !!expressionForRoot && typeof resourcePathToMatch === 'string' && !!expressionForRoot(resourcePathToMatch, undefined, hasSibling);
|
|
2320
2179
|
}
|
|
2321
|
-
|
|
2322
|
-
|
|
2180
|
+
};
|
|
2181
|
+
ResourceGlobMatcher.NO_ROOT = null;
|
|
2182
|
+
ResourceGlobMatcher = ( (__decorate([
|
|
2183
|
+
( (__param(2, IWorkspaceContextService))),
|
|
2184
|
+
( (__param(3, IConfigurationService)))
|
|
2185
|
+
], ResourceGlobMatcher)));
|
|
2186
|
+
const UNDO_REDO_SOURCE = ( (new UndoRedoSource()));
|
|
2187
|
+
let ExplorerService = class ExplorerService {
|
|
2188
|
+
constructor(fileService, configurationService, contextService, clipboardService, editorService, uriIdentityService, bulkEditService, progressService, hostService) {
|
|
2189
|
+
this.fileService = fileService;
|
|
2190
|
+
this.configurationService = configurationService;
|
|
2191
|
+
this.contextService = contextService;
|
|
2192
|
+
this.clipboardService = clipboardService;
|
|
2193
|
+
this.editorService = editorService;
|
|
2194
|
+
this.uriIdentityService = uriIdentityService;
|
|
2195
|
+
this.bulkEditService = bulkEditService;
|
|
2196
|
+
this.progressService = progressService;
|
|
2197
|
+
this.disposables = ( (new DisposableStore()));
|
|
2198
|
+
this.fileChangeEvents = [];
|
|
2199
|
+
this.config = this.configurationService.getValue('explorer');
|
|
2200
|
+
this.model = ( (new ExplorerModel(
|
|
2201
|
+
this.contextService,
|
|
2202
|
+
this.uriIdentityService,
|
|
2203
|
+
this.fileService,
|
|
2204
|
+
this.configurationService
|
|
2205
|
+
)));
|
|
2206
|
+
this.disposables.add(this.model);
|
|
2207
|
+
this.disposables.add(this.fileService.onDidRunOperation(e => this.onDidRunOperation(e)));
|
|
2208
|
+
this.onFileChangesScheduler = ( (new RunOnceScheduler(async () => {
|
|
2209
|
+
const events = this.fileChangeEvents;
|
|
2210
|
+
this.fileChangeEvents = [];
|
|
2211
|
+
const types = [2 ];
|
|
2212
|
+
if (this.config.sortOrder === "modified" ) {
|
|
2213
|
+
types.push(0 );
|
|
2214
|
+
}
|
|
2215
|
+
let shouldRefresh = false;
|
|
2216
|
+
this.roots.forEach(r => {
|
|
2217
|
+
if (this.view && !shouldRefresh) {
|
|
2218
|
+
shouldRefresh = doesFileEventAffect(r, this.view, events, types);
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2221
|
+
events.forEach(e => {
|
|
2222
|
+
if (!shouldRefresh) {
|
|
2223
|
+
for (const resource of e.rawAdded) {
|
|
2224
|
+
const parent = this.model.findClosest(dirname(resource));
|
|
2225
|
+
if (parent && !parent.getChild(basename(resource))) {
|
|
2226
|
+
shouldRefresh = true;
|
|
2227
|
+
break;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
if (shouldRefresh) {
|
|
2233
|
+
await this.refresh(false);
|
|
2234
|
+
}
|
|
2235
|
+
}, ExplorerService.EXPLORER_FILE_CHANGES_REACT_DELAY)));
|
|
2236
|
+
this.disposables.add(this.fileService.onDidFilesChange(e => {
|
|
2237
|
+
this.fileChangeEvents.push(e);
|
|
2238
|
+
if (this.editable) {
|
|
2239
|
+
return;
|
|
2240
|
+
}
|
|
2241
|
+
if (!this.onFileChangesScheduler.isScheduled()) {
|
|
2242
|
+
this.onFileChangesScheduler.schedule();
|
|
2243
|
+
}
|
|
2244
|
+
}));
|
|
2245
|
+
this.disposables.add(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e)));
|
|
2246
|
+
this.disposables.add(Event.any(this.fileService.onDidChangeFileSystemProviderRegistrations, this.fileService.onDidChangeFileSystemProviderCapabilities)(async (e) => {
|
|
2247
|
+
let affected = false;
|
|
2248
|
+
this.model.roots.forEach(r => {
|
|
2249
|
+
if (r.resource.scheme === e.scheme) {
|
|
2250
|
+
affected = true;
|
|
2251
|
+
r.forgetChildren();
|
|
2252
|
+
}
|
|
2253
|
+
});
|
|
2254
|
+
if (affected) {
|
|
2255
|
+
if (this.view) {
|
|
2256
|
+
await this.view.setTreeInput();
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
}));
|
|
2260
|
+
this.disposables.add(this.model.onDidChangeRoots(() => {
|
|
2261
|
+
this.view?.setTreeInput();
|
|
2262
|
+
}));
|
|
2263
|
+
this.disposables.add(hostService.onDidChangeFocus(hasFocus => {
|
|
2264
|
+
if (hasFocus) {
|
|
2265
|
+
this.refresh(false);
|
|
2266
|
+
}
|
|
2267
|
+
}));
|
|
2268
|
+
this.revealExcludeMatcher = ( (new ResourceGlobMatcher(
|
|
2269
|
+
(uri) => getRevealExcludes(configurationService.getValue({ resource: uri })),
|
|
2270
|
+
(event) => event.affectsConfiguration('explorer.autoRevealExclude'),
|
|
2271
|
+
contextService,
|
|
2272
|
+
configurationService
|
|
2273
|
+
)));
|
|
2274
|
+
this.disposables.add(this.revealExcludeMatcher);
|
|
2275
|
+
}
|
|
2276
|
+
get roots() {
|
|
2277
|
+
return this.model.roots;
|
|
2278
|
+
}
|
|
2279
|
+
get sortOrderConfiguration() {
|
|
2323
2280
|
return {
|
|
2324
|
-
|
|
2325
|
-
|
|
2281
|
+
sortOrder: this.config.sortOrder,
|
|
2282
|
+
lexicographicOptions: this.config.sortOrderLexicographicOptions,
|
|
2326
2283
|
};
|
|
2327
2284
|
}
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2285
|
+
registerView(contextProvider) {
|
|
2286
|
+
this.view = contextProvider;
|
|
2287
|
+
}
|
|
2288
|
+
getContext(respectMultiSelection, ignoreNestedChildren = false) {
|
|
2289
|
+
if (!this.view) {
|
|
2290
|
+
return [];
|
|
2291
|
+
}
|
|
2292
|
+
const items = ( (new Set(this.view.getContext(respectMultiSelection))));
|
|
2293
|
+
items.forEach(item => {
|
|
2294
|
+
try {
|
|
2295
|
+
if (respectMultiSelection && !ignoreNestedChildren && this.view?.isItemCollapsed(item) && item.nestedChildren) {
|
|
2296
|
+
for (const child of item.nestedChildren) {
|
|
2297
|
+
items.add(child);
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2333
2300
|
}
|
|
2334
|
-
|
|
2335
|
-
|
|
2301
|
+
catch {
|
|
2302
|
+
return;
|
|
2336
2303
|
}
|
|
2304
|
+
});
|
|
2305
|
+
return [...items];
|
|
2306
|
+
}
|
|
2307
|
+
async applyBulkEdit(edit, options) {
|
|
2308
|
+
const cancellationTokenSource = ( (new CancellationTokenSource()));
|
|
2309
|
+
const promise = this.progressService.withProgress({
|
|
2310
|
+
location: options.progressLocation || 10 ,
|
|
2311
|
+
title: options.progressLabel,
|
|
2312
|
+
cancellable: edit.length > 1,
|
|
2313
|
+
delay: 500,
|
|
2314
|
+
}, async (progress) => {
|
|
2315
|
+
await this.bulkEditService.apply(edit, {
|
|
2316
|
+
undoRedoSource: UNDO_REDO_SOURCE,
|
|
2317
|
+
label: options.undoLabel,
|
|
2318
|
+
code: 'undoredo.explorerOperation',
|
|
2319
|
+
progress,
|
|
2320
|
+
token: cancellationTokenSource.token,
|
|
2321
|
+
confirmBeforeUndo: options.confirmBeforeUndo
|
|
2322
|
+
});
|
|
2323
|
+
}, () => cancellationTokenSource.cancel());
|
|
2324
|
+
await this.progressService.withProgress({ location: 1 , delay: 500 }, () => promise);
|
|
2325
|
+
cancellationTokenSource.dispose();
|
|
2326
|
+
}
|
|
2327
|
+
hasViewFocus() {
|
|
2328
|
+
return !!this.view && this.view.hasFocus();
|
|
2329
|
+
}
|
|
2330
|
+
findClosest(resource) {
|
|
2331
|
+
return this.model.findClosest(resource);
|
|
2332
|
+
}
|
|
2333
|
+
findClosestRoot(resource) {
|
|
2334
|
+
const parentRoots = this.model.roots.filter(r => this.uriIdentityService.extUri.isEqualOrParent(resource, r.resource))
|
|
2335
|
+
.sort((first, second) => second.resource.path.length - first.resource.path.length);
|
|
2336
|
+
return parentRoots.length ? parentRoots[0] : null;
|
|
2337
|
+
}
|
|
2338
|
+
async setEditable(stat, data) {
|
|
2339
|
+
if (!this.view) {
|
|
2340
|
+
return;
|
|
2337
2341
|
}
|
|
2338
|
-
|
|
2339
|
-
|
|
2342
|
+
if (!data) {
|
|
2343
|
+
this.editable = undefined;
|
|
2340
2344
|
}
|
|
2341
|
-
else
|
|
2342
|
-
|
|
2345
|
+
else {
|
|
2346
|
+
this.editable = { stat, data };
|
|
2343
2347
|
}
|
|
2344
|
-
const
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
}
|
|
2348
|
+
const isEditing = this.isEditable(stat);
|
|
2349
|
+
await this.view.setEditable(stat, isEditing);
|
|
2350
|
+
if (!this.editable && this.fileChangeEvents.length && !this.onFileChangesScheduler.isScheduled()) {
|
|
2351
|
+
this.onFileChangesScheduler.schedule();
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
async setToCopy(items, cut) {
|
|
2355
|
+
const previouslyCutItems = this.cutItems;
|
|
2356
|
+
this.cutItems = cut ? items : undefined;
|
|
2357
|
+
await this.clipboardService.writeResources(( (items.map(s => s.resource))));
|
|
2358
|
+
this.view?.itemsCopied(items, cut, previouslyCutItems);
|
|
2359
|
+
}
|
|
2360
|
+
isCut(item) {
|
|
2361
|
+
return !!this.cutItems && this.cutItems.some(i => this.uriIdentityService.extUri.isEqual(i.resource, item.resource));
|
|
2362
|
+
}
|
|
2363
|
+
getEditable() {
|
|
2364
|
+
return this.editable;
|
|
2349
2365
|
}
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2366
|
+
getEditableData(stat) {
|
|
2367
|
+
return this.editable && this.editable.stat === stat ? this.editable.data : undefined;
|
|
2368
|
+
}
|
|
2369
|
+
isEditable(stat) {
|
|
2370
|
+
return !!this.editable && (this.editable.stat === stat || !stat);
|
|
2371
|
+
}
|
|
2372
|
+
async select(resource, reveal) {
|
|
2373
|
+
if (!this.view) {
|
|
2374
|
+
return;
|
|
2355
2375
|
}
|
|
2356
|
-
|
|
2357
|
-
|
|
2376
|
+
const ignoreRevealExcludes = reveal === 'force';
|
|
2377
|
+
const fileStat = this.findClosest(resource);
|
|
2378
|
+
if (fileStat) {
|
|
2379
|
+
if (!this.shouldAutoRevealItem(fileStat, ignoreRevealExcludes)) {
|
|
2380
|
+
return;
|
|
2381
|
+
}
|
|
2382
|
+
await this.view.selectResource(fileStat.resource, reveal);
|
|
2383
|
+
return Promise.resolve(undefined);
|
|
2358
2384
|
}
|
|
2359
|
-
|
|
2360
|
-
|
|
2385
|
+
const options = { resolveTo: [resource], resolveMetadata: this.config.sortOrder === "modified" };
|
|
2386
|
+
const root = this.findClosestRoot(resource);
|
|
2387
|
+
if (!root) {
|
|
2388
|
+
return undefined;
|
|
2389
|
+
}
|
|
2390
|
+
try {
|
|
2391
|
+
const stat = await this.fileService.resolve(root.resource, options);
|
|
2392
|
+
const modelStat = ExplorerItem.create(this.fileService, this.configurationService, stat, undefined, options.resolveTo);
|
|
2393
|
+
ExplorerItem.mergeLocalWithDisk(modelStat, root);
|
|
2394
|
+
const item = root.find(resource);
|
|
2395
|
+
await this.view.refresh(true, root);
|
|
2396
|
+
if (item && !this.shouldAutoRevealItem(item, ignoreRevealExcludes)) {
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
await this.view.selectResource(item ? item.resource : undefined, reveal);
|
|
2361
2400
|
}
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2401
|
+
catch (error) {
|
|
2402
|
+
root.error = error;
|
|
2403
|
+
await this.view.refresh(false, root);
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
async refresh(reveal = true) {
|
|
2407
|
+
this.model.roots.forEach(r => r.forgetChildren());
|
|
2408
|
+
if (this.view) {
|
|
2409
|
+
await this.view.refresh(true);
|
|
2410
|
+
const resource = this.editorService.activeEditor?.resource;
|
|
2411
|
+
const autoReveal = this.configurationService.getValue().explorer.autoReveal;
|
|
2412
|
+
if (reveal && resource && autoReveal) {
|
|
2413
|
+
this.select(resource, autoReveal);
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
async onDidRunOperation(e) {
|
|
2418
|
+
const shouldDeepRefresh = this.config.fileNesting.enabled;
|
|
2419
|
+
if (e.isOperation(0 ) || e.isOperation(3 )) {
|
|
2420
|
+
const addedElement = e.target;
|
|
2421
|
+
const parentResource = dirname(addedElement.resource);
|
|
2422
|
+
const parents = this.model.findAll(parentResource);
|
|
2423
|
+
if (parents.length) {
|
|
2424
|
+
await Promise.all(( (parents.map(async (p) => {
|
|
2425
|
+
const resolveMetadata = this.config.sortOrder === `modified`;
|
|
2426
|
+
if (!p.isDirectoryResolved) {
|
|
2427
|
+
const stat = await this.fileService.resolve(p.resource, { resolveMetadata });
|
|
2428
|
+
if (stat) {
|
|
2429
|
+
const modelStat = ExplorerItem.create(this.fileService, this.configurationService, stat, p.parent);
|
|
2430
|
+
ExplorerItem.mergeLocalWithDisk(modelStat, p);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
const childElement = ExplorerItem.create(this.fileService, this.configurationService, addedElement, p.parent);
|
|
2434
|
+
p.removeChild(childElement);
|
|
2435
|
+
p.addChild(childElement);
|
|
2436
|
+
await this.view?.refresh(shouldDeepRefresh, p);
|
|
2437
|
+
}))));
|
|
2365
2438
|
}
|
|
2366
2439
|
}
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2440
|
+
else if (e.isOperation(2 )) {
|
|
2441
|
+
const oldResource = e.resource;
|
|
2442
|
+
const newElement = e.target;
|
|
2443
|
+
const oldParentResource = dirname(oldResource);
|
|
2444
|
+
const newParentResource = dirname(newElement.resource);
|
|
2445
|
+
const modelElements = this.model.findAll(oldResource);
|
|
2446
|
+
const sameParentMove = modelElements.every(e => !e.nestedParent) && this.uriIdentityService.extUri.isEqual(oldParentResource, newParentResource);
|
|
2447
|
+
if (sameParentMove) {
|
|
2448
|
+
await Promise.all(( (modelElements.map(async (modelElement) => {
|
|
2449
|
+
modelElement.rename(newElement);
|
|
2450
|
+
await this.view?.refresh(shouldDeepRefresh, modelElement.parent);
|
|
2451
|
+
}))));
|
|
2452
|
+
}
|
|
2453
|
+
else {
|
|
2454
|
+
const newParents = this.model.findAll(newParentResource);
|
|
2455
|
+
if (newParents.length && modelElements.length) {
|
|
2456
|
+
await Promise.all(( (modelElements.map(async (modelElement, index) => {
|
|
2457
|
+
const oldParent = modelElement.parent;
|
|
2458
|
+
const oldNestedParent = modelElement.nestedParent;
|
|
2459
|
+
modelElement.move(newParents[index]);
|
|
2460
|
+
if (oldNestedParent) {
|
|
2461
|
+
await this.view?.refresh(false, oldNestedParent);
|
|
2462
|
+
}
|
|
2463
|
+
await this.view?.refresh(false, oldParent);
|
|
2464
|
+
await this.view?.refresh(shouldDeepRefresh, newParents[index]);
|
|
2465
|
+
}))));
|
|
2374
2466
|
}
|
|
2375
|
-
|
|
2376
|
-
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
else if (e.isOperation(1 )) {
|
|
2470
|
+
const modelElements = this.model.findAll(e.resource);
|
|
2471
|
+
await Promise.all(( (modelElements.map(async (modelElement) => {
|
|
2472
|
+
if (modelElement.parent) {
|
|
2473
|
+
const parent = modelElement.parent;
|
|
2474
|
+
parent.removeChild(modelElement);
|
|
2475
|
+
const oldNestedParent = modelElement.nestedParent;
|
|
2476
|
+
if (oldNestedParent) {
|
|
2477
|
+
oldNestedParent.removeChild(modelElement);
|
|
2478
|
+
await this.view?.refresh(false, oldNestedParent);
|
|
2479
|
+
}
|
|
2480
|
+
await this.view?.refresh(shouldDeepRefresh, parent);
|
|
2377
2481
|
}
|
|
2482
|
+
}))));
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
shouldAutoRevealItem(item, ignore) {
|
|
2486
|
+
if (item === undefined || ignore) {
|
|
2487
|
+
return true;
|
|
2488
|
+
}
|
|
2489
|
+
if (this.revealExcludeMatcher.matches(item.resource, name => !!(item.parent && item.parent.getChild(name)))) {
|
|
2490
|
+
return false;
|
|
2491
|
+
}
|
|
2492
|
+
const root = item.root;
|
|
2493
|
+
let currentItem = item.parent;
|
|
2494
|
+
while (currentItem !== root) {
|
|
2495
|
+
if (currentItem === undefined) {
|
|
2496
|
+
return true;
|
|
2497
|
+
}
|
|
2498
|
+
if (this.revealExcludeMatcher.matches(currentItem.resource)) {
|
|
2499
|
+
return false;
|
|
2378
2500
|
}
|
|
2501
|
+
currentItem = currentItem.parent;
|
|
2502
|
+
}
|
|
2503
|
+
return true;
|
|
2504
|
+
}
|
|
2505
|
+
async onConfigurationUpdated(event) {
|
|
2506
|
+
if (!event.affectsConfiguration('explorer')) {
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
let shouldRefresh = false;
|
|
2510
|
+
if (event.affectsConfiguration('explorer.fileNesting')) {
|
|
2511
|
+
shouldRefresh = true;
|
|
2512
|
+
}
|
|
2513
|
+
const configuration = this.configurationService.getValue();
|
|
2514
|
+
const configSortOrder = configuration?.explorer?.sortOrder || "default" ;
|
|
2515
|
+
if (this.config.sortOrder !== configSortOrder) {
|
|
2516
|
+
shouldRefresh = this.config.sortOrder !== undefined;
|
|
2517
|
+
}
|
|
2518
|
+
const configLexicographicOptions = configuration?.explorer?.sortOrderLexicographicOptions || "default" ;
|
|
2519
|
+
if (this.config.sortOrderLexicographicOptions !== configLexicographicOptions) {
|
|
2520
|
+
shouldRefresh = shouldRefresh || this.config.sortOrderLexicographicOptions !== undefined;
|
|
2379
2521
|
}
|
|
2380
|
-
|
|
2522
|
+
this.config = configuration.explorer;
|
|
2523
|
+
if (shouldRefresh) {
|
|
2524
|
+
await this.refresh();
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
dispose() {
|
|
2528
|
+
this.disposables.dispose();
|
|
2381
2529
|
}
|
|
2382
2530
|
};
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
( (__param(
|
|
2531
|
+
ExplorerService.EXPLORER_FILE_CHANGES_REACT_DELAY = 500;
|
|
2532
|
+
ExplorerService = ( (__decorate([
|
|
2533
|
+
( (__param(0, IFileService))),
|
|
2534
|
+
( (__param(1, IConfigurationService))),
|
|
2386
2535
|
( (__param(2, IWorkspaceContextService))),
|
|
2387
|
-
( (__param(3,
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2536
|
+
( (__param(3, IClipboardService))),
|
|
2537
|
+
( (__param(4, IEditorService))),
|
|
2538
|
+
( (__param(5, IUriIdentityService))),
|
|
2539
|
+
( (__param(6, IBulkEditService))),
|
|
2540
|
+
( (__param(7, IProgressService))),
|
|
2541
|
+
( (__param(8, IHostService)))
|
|
2542
|
+
], ExplorerService)));
|
|
2543
|
+
function doesFileEventAffect(item, view, events, types) {
|
|
2544
|
+
for (const [_name, child] of item.children) {
|
|
2545
|
+
if (view.isItemVisible(child)) {
|
|
2546
|
+
if (events.some(e => e.contains(child.resource, ...types))) {
|
|
2547
|
+
return true;
|
|
2548
|
+
}
|
|
2549
|
+
if (child.isDirectory && child.isDirectoryResolved) {
|
|
2550
|
+
if (doesFileEventAffect(child, view, events, types)) {
|
|
2551
|
+
return true;
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2393
2555
|
}
|
|
2394
|
-
|
|
2395
|
-
|
|
2556
|
+
return false;
|
|
2557
|
+
}
|
|
2558
|
+
function getRevealExcludes(configuration) {
|
|
2559
|
+
const revealExcludes = configuration && configuration.explorer && configuration.explorer.autoRevealExclude;
|
|
2560
|
+
if (!revealExcludes) {
|
|
2561
|
+
return {};
|
|
2396
2562
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2563
|
+
return revealExcludes;
|
|
2564
|
+
}
|
|
2565
|
+
( (Registry.as(EditorExtensions.EditorFactory))).registerFileEditorFactory({
|
|
2566
|
+
typeId: FILE_EDITOR_INPUT_ID,
|
|
2567
|
+
createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService) => {
|
|
2568
|
+
return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents);
|
|
2569
|
+
},
|
|
2570
|
+
isFileEditor: (obj) => {
|
|
2571
|
+
return obj instanceof FileEditorInput;
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
const configurationRegistry = ( (Registry.as(Extensions.Configuration)));
|
|
2575
|
+
const hotExitConfiguration = isNative ?
|
|
2576
|
+
{
|
|
2577
|
+
'type': 'string',
|
|
2578
|
+
'scope': 1 ,
|
|
2579
|
+
'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],
|
|
2580
|
+
'default': HotExitConfiguration.ON_EXIT,
|
|
2581
|
+
'markdownEnumDescriptions': [
|
|
2582
|
+
( (localize(
|
|
2583
|
+
'hotExit.off',
|
|
2584
|
+
'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'
|
|
2585
|
+
))),
|
|
2586
|
+
( (localize(
|
|
2587
|
+
'hotExit.onExit',
|
|
2588
|
+
'Hot exit will be triggered when the last window is closed on Windows/Linux or when the `workbench.action.quit` command is triggered (command palette, keybinding, menu). All windows without folders opened will be restored upon next launch. A list of previously opened windows with unsaved files can be accessed via `File > Open Recent > More...`'
|
|
2589
|
+
))),
|
|
2590
|
+
( (localize(
|
|
2591
|
+
'hotExit.onExitAndWindowClose',
|
|
2592
|
+
'Hot exit will be triggered when the last window is closed on Windows/Linux or when the `workbench.action.quit` command is triggered (command palette, keybinding, menu), and also for any window with a folder opened regardless of whether it\'s the last window. All windows without folders opened will be restored upon next launch. A list of previously opened windows with unsaved files can be accessed via `File > Open Recent > More...`'
|
|
2593
|
+
)))
|
|
2594
|
+
],
|
|
2595
|
+
'description': ( (localize(
|
|
2596
|
+
'hotExit',
|
|
2597
|
+
"Controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.",
|
|
2598
|
+
HotExitConfiguration.ON_EXIT,
|
|
2599
|
+
HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE
|
|
2600
|
+
)))
|
|
2601
|
+
} : {
|
|
2602
|
+
'type': 'string',
|
|
2603
|
+
'scope': 1 ,
|
|
2604
|
+
'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],
|
|
2605
|
+
'default': HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE,
|
|
2606
|
+
'markdownEnumDescriptions': [
|
|
2607
|
+
( (localize(
|
|
2608
|
+
'hotExit.off',
|
|
2609
|
+
'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'
|
|
2610
|
+
))),
|
|
2611
|
+
( (localize(
|
|
2612
|
+
'hotExit.onExitAndWindowCloseBrowser',
|
|
2613
|
+
'Hot exit will be triggered when the browser quits or the window or tab is closed.'
|
|
2614
|
+
)))
|
|
2615
|
+
],
|
|
2616
|
+
'description': ( (localize(
|
|
2617
|
+
'hotExit',
|
|
2618
|
+
"Controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.",
|
|
2619
|
+
HotExitConfiguration.ON_EXIT,
|
|
2620
|
+
HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE
|
|
2621
|
+
)))
|
|
2622
|
+
};
|
|
2623
|
+
configurationRegistry.registerConfiguration({
|
|
2624
|
+
'id': 'files',
|
|
2625
|
+
'order': 9,
|
|
2626
|
+
'title': ( (localize('filesConfigurationTitle', "Files"))),
|
|
2627
|
+
'type': 'object',
|
|
2628
|
+
'properties': {
|
|
2629
|
+
[FILES_EXCLUDE_CONFIG]: {
|
|
2630
|
+
'type': 'object',
|
|
2631
|
+
'markdownDescription': ( (localize(
|
|
2632
|
+
'exclude',
|
|
2633
|
+
"Configure [glob patterns](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options) for excluding files and folders. For example, the File Explorer decides which files and folders to show or hide based on this setting. Refer to the `#search.exclude#` setting to define search-specific excludes. Refer to the `#explorer.excludeGitIgnore#` setting for ignoring files based on your `.gitignore`."
|
|
2634
|
+
))),
|
|
2635
|
+
'default': {
|
|
2636
|
+
...{ '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true, '**/Thumbs.db': true },
|
|
2637
|
+
...(isWeb ? { '**/*.crswap': true } : undefined)
|
|
2638
|
+
},
|
|
2639
|
+
'scope': 4 ,
|
|
2640
|
+
'additionalProperties': {
|
|
2641
|
+
'anyOf': [
|
|
2642
|
+
{
|
|
2643
|
+
'type': 'boolean',
|
|
2644
|
+
'enum': [true, false],
|
|
2645
|
+
'enumDescriptions': [( (localize('trueDescription', "Enable the pattern."))), ( (localize('falseDescription', "Disable the pattern.")))],
|
|
2646
|
+
'description': ( (localize(
|
|
2647
|
+
'files.exclude.boolean',
|
|
2648
|
+
"The glob pattern to match file paths against. Set to true or false to enable or disable the pattern."
|
|
2649
|
+
))),
|
|
2650
|
+
},
|
|
2651
|
+
{
|
|
2652
|
+
'type': 'object',
|
|
2653
|
+
'properties': {
|
|
2654
|
+
'when': {
|
|
2655
|
+
'type': 'string',
|
|
2656
|
+
'pattern': '\\w*\\$\\(basename\\)\\w*',
|
|
2657
|
+
'default': '$(basename).ext',
|
|
2658
|
+
'markdownDescription': ( (localize(
|
|
2659
|
+
{ key: 'files.exclude.when', comment: ['\\$(basename) should not be translated'] },
|
|
2660
|
+
"Additional check on the siblings of a matching file. Use \\$(basename) as variable for the matching file name."
|
|
2661
|
+
)))
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
]
|
|
2666
|
+
}
|
|
2667
|
+
},
|
|
2668
|
+
[FILES_ASSOCIATIONS_CONFIG]: {
|
|
2669
|
+
'type': 'object',
|
|
2670
|
+
'markdownDescription': ( (localize(
|
|
2671
|
+
'associations',
|
|
2672
|
+
"Configure file associations to languages (for example `\"*.extension\": \"html\"`). These have precedence over the default associations of the languages installed."
|
|
2673
|
+
))),
|
|
2674
|
+
'additionalProperties': {
|
|
2675
|
+
'type': 'string'
|
|
2676
|
+
}
|
|
2677
|
+
},
|
|
2678
|
+
'files.encoding': {
|
|
2679
|
+
'type': 'string',
|
|
2680
|
+
'enum': ( (Object.keys(SUPPORTED_ENCODINGS))),
|
|
2681
|
+
'default': 'utf8',
|
|
2682
|
+
'description': ( (localize(
|
|
2683
|
+
'encoding',
|
|
2684
|
+
"The default character set encoding to use when reading and writing files. This setting can also be configured per language."
|
|
2685
|
+
))),
|
|
2686
|
+
'scope': 5 ,
|
|
2687
|
+
'enumDescriptions': ( (( (Object.keys(SUPPORTED_ENCODINGS))).map(key => SUPPORTED_ENCODINGS[key].labelLong))),
|
|
2688
|
+
'enumItemLabels': ( (( (Object.keys(SUPPORTED_ENCODINGS))).map(key => SUPPORTED_ENCODINGS[key].labelLong)))
|
|
2689
|
+
},
|
|
2690
|
+
'files.autoGuessEncoding': {
|
|
2691
|
+
'type': 'boolean',
|
|
2692
|
+
'default': false,
|
|
2693
|
+
'markdownDescription': ( (localize(
|
|
2694
|
+
'autoGuessEncoding',
|
|
2695
|
+
"When enabled, the editor will attempt to guess the character set encoding when opening files. This setting can also be configured per language. Note, this setting is not respected by text search. Only {0} is respected.",
|
|
2696
|
+
'`#files.encoding#`'
|
|
2697
|
+
))),
|
|
2698
|
+
'scope': 5
|
|
2699
|
+
},
|
|
2700
|
+
'files.eol': {
|
|
2701
|
+
'type': 'string',
|
|
2702
|
+
'enum': [
|
|
2703
|
+
'\n',
|
|
2704
|
+
'\r\n',
|
|
2705
|
+
'auto'
|
|
2706
|
+
],
|
|
2707
|
+
'enumDescriptions': [
|
|
2708
|
+
( (localize('eol.LF', "LF"))),
|
|
2709
|
+
( (localize('eol.CRLF', "CRLF"))),
|
|
2710
|
+
( (localize('eol.auto', "Uses operating system specific end of line character.")))
|
|
2711
|
+
],
|
|
2712
|
+
'default': 'auto',
|
|
2713
|
+
'description': ( (localize('eol', "The default end of line character."))),
|
|
2714
|
+
'scope': 5
|
|
2715
|
+
},
|
|
2716
|
+
'files.enableTrash': {
|
|
2717
|
+
'type': 'boolean',
|
|
2718
|
+
'default': true,
|
|
2719
|
+
'description': ( (localize(
|
|
2720
|
+
'useTrash',
|
|
2721
|
+
"Moves files/folders to the OS trash (recycle bin on Windows) when deleting. Disabling this will delete files/folders permanently."
|
|
2722
|
+
)))
|
|
2723
|
+
},
|
|
2724
|
+
'files.trimTrailingWhitespace': {
|
|
2725
|
+
'type': 'boolean',
|
|
2726
|
+
'default': false,
|
|
2727
|
+
'description': ( (localize(
|
|
2728
|
+
'trimTrailingWhitespace',
|
|
2729
|
+
"When enabled, will trim trailing whitespace when saving a file."
|
|
2730
|
+
))),
|
|
2731
|
+
'scope': 5
|
|
2732
|
+
},
|
|
2733
|
+
'files.insertFinalNewline': {
|
|
2734
|
+
'type': 'boolean',
|
|
2735
|
+
'default': false,
|
|
2736
|
+
'description': ( (localize(
|
|
2737
|
+
'insertFinalNewline',
|
|
2738
|
+
"When enabled, insert a final new line at the end of the file when saving it."
|
|
2739
|
+
))),
|
|
2740
|
+
'scope': 5
|
|
2741
|
+
},
|
|
2742
|
+
'files.trimFinalNewlines': {
|
|
2743
|
+
'type': 'boolean',
|
|
2744
|
+
'default': false,
|
|
2745
|
+
'description': ( (localize(
|
|
2746
|
+
'trimFinalNewlines',
|
|
2747
|
+
"When enabled, will trim all new lines after the final new line at the end of the file when saving it."
|
|
2748
|
+
))),
|
|
2749
|
+
scope: 5 ,
|
|
2750
|
+
},
|
|
2751
|
+
'files.autoSave': {
|
|
2752
|
+
'type': 'string',
|
|
2753
|
+
'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],
|
|
2754
|
+
'markdownEnumDescriptions': [
|
|
2755
|
+
( (localize(
|
|
2756
|
+
{ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.off' },
|
|
2757
|
+
"An editor with changes is never automatically saved."
|
|
2758
|
+
))),
|
|
2759
|
+
( (localize(
|
|
2760
|
+
{ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.afterDelay' },
|
|
2761
|
+
"An editor with changes is automatically saved after the configured `#files.autoSaveDelay#`."
|
|
2762
|
+
))),
|
|
2763
|
+
( (localize(
|
|
2764
|
+
{ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onFocusChange' },
|
|
2765
|
+
"An editor with changes is automatically saved when the editor loses focus."
|
|
2766
|
+
))),
|
|
2767
|
+
( (localize(
|
|
2768
|
+
{ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onWindowChange' },
|
|
2769
|
+
"An editor with changes is automatically saved when the window loses focus."
|
|
2770
|
+
)))
|
|
2771
|
+
],
|
|
2772
|
+
'default': isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF,
|
|
2773
|
+
'markdownDescription': ( (localize(
|
|
2774
|
+
{ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSave' },
|
|
2775
|
+
"Controls [auto save](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save) of editors that have unsaved changes.",
|
|
2776
|
+
AutoSaveConfiguration.OFF,
|
|
2777
|
+
AutoSaveConfiguration.AFTER_DELAY,
|
|
2778
|
+
AutoSaveConfiguration.ON_FOCUS_CHANGE,
|
|
2779
|
+
AutoSaveConfiguration.ON_WINDOW_CHANGE,
|
|
2780
|
+
AutoSaveConfiguration.AFTER_DELAY
|
|
2781
|
+
)))
|
|
2782
|
+
},
|
|
2783
|
+
'files.autoSaveDelay': {
|
|
2784
|
+
'type': 'number',
|
|
2785
|
+
'default': 1000,
|
|
2786
|
+
'minimum': 0,
|
|
2787
|
+
'markdownDescription': ( (localize(
|
|
2788
|
+
{ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSaveDelay' },
|
|
2789
|
+
"Controls the delay in milliseconds after which an editor with unsaved changes is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.",
|
|
2790
|
+
AutoSaveConfiguration.AFTER_DELAY
|
|
2791
|
+
)))
|
|
2792
|
+
},
|
|
2793
|
+
'files.watcherExclude': {
|
|
2794
|
+
'type': 'object',
|
|
2795
|
+
'default': { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/node_modules/*/**': true, '**/.hg/store/**': true },
|
|
2796
|
+
'markdownDescription': ( (localize(
|
|
2797
|
+
'watcherExclude',
|
|
2798
|
+
"Configure paths or glob patterns to exclude from file watching. Paths can either be relative to the watched folder or absolute. Glob patterns are matched relative from the watched folder. When you experience the file watcher process consuming a lot of CPU, make sure to exclude large folders that are of less interest (such as build output folders)."
|
|
2799
|
+
))),
|
|
2800
|
+
'scope': 4
|
|
2801
|
+
},
|
|
2802
|
+
'files.watcherInclude': {
|
|
2803
|
+
'type': 'array',
|
|
2804
|
+
'items': {
|
|
2805
|
+
'type': 'string'
|
|
2806
|
+
},
|
|
2807
|
+
'default': [],
|
|
2808
|
+
'description': ( (localize(
|
|
2809
|
+
'watcherInclude',
|
|
2810
|
+
"Configure extra paths to watch for changes inside the workspace. By default, all workspace folders will be watched recursively, except for folders that are symbolic links. You can explicitly add absolute or relative paths to support watching folders that are symbolic links. Relative paths will be resolved to an absolute path using the currently opened workspace."
|
|
2811
|
+
))),
|
|
2812
|
+
'scope': 4
|
|
2813
|
+
},
|
|
2814
|
+
'files.hotExit': hotExitConfiguration,
|
|
2815
|
+
'files.defaultLanguage': {
|
|
2816
|
+
'type': 'string',
|
|
2817
|
+
'markdownDescription': ( (localize(
|
|
2818
|
+
'defaultLanguage',
|
|
2819
|
+
"The default language identifier that is assigned to new files. If configured to `${activeEditorLanguage}`, will use the language identifier of the currently active text editor if any."
|
|
2820
|
+
)))
|
|
2821
|
+
},
|
|
2822
|
+
'files.maxMemoryForLargeFilesMB': {
|
|
2823
|
+
'type': 'number',
|
|
2824
|
+
'default': 4096,
|
|
2825
|
+
'minimum': 0,
|
|
2826
|
+
'markdownDescription': ( (localize(
|
|
2827
|
+
'maxMemoryForLargeFilesMB',
|
|
2828
|
+
"Controls the memory available to VS Code after restart when trying to open large files. Same effect as specifying `--max-memory=NEWSIZE` on the command line."
|
|
2829
|
+
))),
|
|
2830
|
+
included: isNative
|
|
2831
|
+
},
|
|
2832
|
+
'files.restoreUndoStack': {
|
|
2833
|
+
'type': 'boolean',
|
|
2834
|
+
'description': ( (localize(
|
|
2835
|
+
'files.restoreUndoStack',
|
|
2836
|
+
"Restore the undo stack when a file is reopened."
|
|
2837
|
+
))),
|
|
2838
|
+
'default': true
|
|
2839
|
+
},
|
|
2840
|
+
'files.saveConflictResolution': {
|
|
2841
|
+
'type': 'string',
|
|
2842
|
+
'enum': [
|
|
2843
|
+
'askUser',
|
|
2844
|
+
'overwriteFileOnDisk'
|
|
2845
|
+
],
|
|
2846
|
+
'enumDescriptions': [
|
|
2847
|
+
( (localize(
|
|
2848
|
+
'askUser',
|
|
2849
|
+
"Will refuse to save and ask for resolving the save conflict manually."
|
|
2850
|
+
))),
|
|
2851
|
+
( (localize(
|
|
2852
|
+
'overwriteFileOnDisk',
|
|
2853
|
+
"Will resolve the save conflict by overwriting the file on disk with the changes in the editor."
|
|
2854
|
+
)))
|
|
2855
|
+
],
|
|
2856
|
+
'description': ( (localize(
|
|
2857
|
+
'files.saveConflictResolution',
|
|
2858
|
+
"A save conflict can occur when a file is saved to disk that was changed by another program in the meantime. To prevent data loss, the user is asked to compare the changes in the editor with the version on disk. This setting should only be changed if you frequently encounter save conflict errors and may result in data loss if used without caution."
|
|
2859
|
+
))),
|
|
2860
|
+
'default': 'askUser',
|
|
2861
|
+
'scope': 5
|
|
2862
|
+
},
|
|
2863
|
+
'files.simpleDialog.enable': {
|
|
2864
|
+
'type': 'boolean',
|
|
2865
|
+
'description': ( (localize(
|
|
2866
|
+
'files.simpleDialog.enable',
|
|
2867
|
+
"Enables the simple file dialog. The simple file dialog replaces the system file dialog when enabled."
|
|
2868
|
+
))),
|
|
2869
|
+
'default': false
|
|
2870
|
+
},
|
|
2871
|
+
'files.participants.timeout': {
|
|
2872
|
+
type: 'number',
|
|
2873
|
+
default: 60000,
|
|
2874
|
+
markdownDescription: ( (localize(
|
|
2875
|
+
'files.participants.timeout',
|
|
2876
|
+
"Timeout in milliseconds after which file participants for create, rename, and delete are cancelled. Use `0` to disable participants."
|
|
2877
|
+
))),
|
|
2400
2878
|
}
|
|
2401
|
-
return false;
|
|
2402
2879
|
}
|
|
2403
|
-
};
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2880
|
+
});
|
|
2881
|
+
configurationRegistry.registerConfiguration({
|
|
2882
|
+
...editorConfigurationBaseNode,
|
|
2883
|
+
properties: {
|
|
2884
|
+
'editor.formatOnSave': {
|
|
2885
|
+
'type': 'boolean',
|
|
2886
|
+
'description': ( (localize(
|
|
2887
|
+
'formatOnSave',
|
|
2888
|
+
"Format a file on save. A formatter must be available, the file must not be saved after delay, and the editor must not be shutting down."
|
|
2889
|
+
))),
|
|
2890
|
+
'scope': 5 ,
|
|
2891
|
+
},
|
|
2892
|
+
'editor.formatOnSaveMode': {
|
|
2893
|
+
'type': 'string',
|
|
2894
|
+
'default': 'file',
|
|
2895
|
+
'enum': [
|
|
2896
|
+
'file',
|
|
2897
|
+
'modifications',
|
|
2898
|
+
'modificationsIfAvailable'
|
|
2899
|
+
],
|
|
2900
|
+
'enumDescriptions': [
|
|
2901
|
+
( (localize(
|
|
2902
|
+
{ key: 'everything', comment: ['This is the description of an option'] },
|
|
2903
|
+
"Format the whole file."
|
|
2904
|
+
))),
|
|
2905
|
+
( (localize(
|
|
2906
|
+
{ key: 'modification', comment: ['This is the description of an option'] },
|
|
2907
|
+
"Format modifications (requires source control)."
|
|
2908
|
+
))),
|
|
2909
|
+
( (localize(
|
|
2910
|
+
{ key: 'modificationIfAvailable', comment: ['This is the description of an option'] },
|
|
2911
|
+
"Will attempt to format modifications only (requires source control). If source control can't be used, then the whole file will be formatted."
|
|
2912
|
+
))),
|
|
2913
|
+
],
|
|
2914
|
+
'markdownDescription': ( (localize(
|
|
2915
|
+
'formatOnSaveMode',
|
|
2916
|
+
"Controls if format on save formats the whole file or only modifications. Only applies when `#editor.formatOnSave#` is enabled."
|
|
2917
|
+
))),
|
|
2918
|
+
'scope': 5 ,
|
|
2919
|
+
},
|
|
2920
|
+
}
|
|
2921
|
+
});
|
|
2922
|
+
RedoCommand.addImplementation(110, 'explorer', (accessor) => {
|
|
2923
|
+
const undoRedoService = accessor.get(IUndoRedoService);
|
|
2924
|
+
const explorerService = accessor.get(IExplorerService);
|
|
2925
|
+
const configurationService = accessor.get(IConfigurationService);
|
|
2926
|
+
const explorerCanUndo = configurationService.getValue().explorer.enableUndo;
|
|
2927
|
+
if (explorerService.hasViewFocus() && undoRedoService.canRedo(UNDO_REDO_SOURCE) && explorerCanUndo) {
|
|
2928
|
+
undoRedoService.redo(UNDO_REDO_SOURCE);
|
|
2929
|
+
return true;
|
|
2431
2930
|
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
], SimpleExtensionResourceLoaderService));
|
|
2440
|
-
registerSingleton(IExtensionResourceLoaderService, SimpleExtensionResourceLoaderService, 0 );
|
|
2931
|
+
return false;
|
|
2932
|
+
});
|
|
2933
|
+
ModesRegistry.registerLanguage({
|
|
2934
|
+
id: BINARY_TEXT_FILE_MODE,
|
|
2935
|
+
aliases: ['Binary'],
|
|
2936
|
+
mimetypes: ['text/x-code-binary']
|
|
2937
|
+
});
|
|
2441
2938
|
class File {
|
|
2442
2939
|
constructor(getContent) {
|
|
2443
2940
|
this.getContent = getContent;
|
|
@@ -2448,17 +2945,71 @@ class File {
|
|
|
2448
2945
|
}
|
|
2449
2946
|
}
|
|
2450
2947
|
const encoder = new TextEncoder();
|
|
2451
|
-
|
|
2948
|
+
const decoder = new TextDecoder();
|
|
2949
|
+
class SimpleTextFileSystemProvider {
|
|
2452
2950
|
constructor() {
|
|
2951
|
+
this.onDidChangeCapabilities = Event.None;
|
|
2453
2952
|
this.capabilities = 2 | 1024 ;
|
|
2454
2953
|
this.onDidChangeFile = Event.None;
|
|
2455
|
-
this.onDidChangeCapabilities = Event.None;
|
|
2456
2954
|
this.onDidWatchError = Event.None;
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2955
|
+
}
|
|
2956
|
+
async readFile(resource) {
|
|
2957
|
+
try {
|
|
2958
|
+
const content = await this.getFileContent(resource);
|
|
2959
|
+
if (content != null) {
|
|
2960
|
+
return encoder.encode(content);
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
catch (err) {
|
|
2964
|
+
throw createFileSystemProviderError(err, FileSystemProviderErrorCode.Unknown);
|
|
2965
|
+
}
|
|
2966
|
+
throw createFileSystemProviderError('file not found', FileSystemProviderErrorCode.FileNotFound);
|
|
2967
|
+
}
|
|
2968
|
+
async writeFile(resource, content, opts) {
|
|
2969
|
+
try {
|
|
2970
|
+
await this.setFileContent(resource, decoder.decode(content), opts);
|
|
2971
|
+
}
|
|
2972
|
+
catch (err) {
|
|
2973
|
+
throw createFileSystemProviderError(err, FileSystemProviderErrorCode.Unknown);
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
watch() {
|
|
2977
|
+
return Disposable.None;
|
|
2978
|
+
}
|
|
2979
|
+
async stat(resource) {
|
|
2980
|
+
try {
|
|
2981
|
+
const content = await this.getFileContent(resource);
|
|
2982
|
+
if (content != null) {
|
|
2983
|
+
return {
|
|
2984
|
+
type: FileType.File,
|
|
2985
|
+
size: encoder.encode(content).length,
|
|
2986
|
+
ctime: Date.now(),
|
|
2987
|
+
mtime: Date.now()
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
catch (err) {
|
|
2992
|
+
throw createFileSystemProviderError(err, FileSystemProviderErrorCode.Unknown);
|
|
2993
|
+
}
|
|
2994
|
+
throw createFileSystemProviderError('file not found', FileSystemProviderErrorCode.FileNotFound);
|
|
2995
|
+
}
|
|
2996
|
+
async mkdir() {
|
|
2997
|
+
}
|
|
2998
|
+
readdir() {
|
|
2999
|
+
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions);
|
|
3000
|
+
}
|
|
3001
|
+
delete() {
|
|
3002
|
+
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions);
|
|
3003
|
+
}
|
|
3004
|
+
rename() {
|
|
3005
|
+
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions);
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
class ExtensionFileSystemProviderWithFileReadWriteCapability {
|
|
3009
|
+
constructor() {
|
|
3010
|
+
this.capabilities = 2 | 1024 | 2048 ;
|
|
3011
|
+
this.onDidChangeFile = Event.None;
|
|
3012
|
+
this.onDidChangeCapabilities = Event.None;
|
|
2462
3013
|
this.files = new Map();
|
|
2463
3014
|
}
|
|
2464
3015
|
async stat(resource) {
|
|
@@ -2476,36 +3027,139 @@ class ExtensionFileSystemProviderWithFileReadWriteCapability {
|
|
|
2476
3027
|
throw FileSystemProviderError.create('file not found', FileSystemProviderErrorCode.FileNotFound);
|
|
2477
3028
|
}
|
|
2478
3029
|
watch() {
|
|
2479
|
-
return
|
|
2480
|
-
dispose() { }
|
|
2481
|
-
};
|
|
3030
|
+
return Disposable.None;
|
|
2482
3031
|
}
|
|
2483
3032
|
registerFile(resource, getContent) {
|
|
2484
3033
|
this.files.set(( resource.toString()), new File(getContent));
|
|
2485
|
-
return
|
|
2486
|
-
|
|
2487
|
-
|
|
3034
|
+
return {
|
|
3035
|
+
dispose: () => {
|
|
3036
|
+
this.files.delete(( resource.toString()));
|
|
3037
|
+
}
|
|
3038
|
+
};
|
|
3039
|
+
}
|
|
3040
|
+
async writeFile() {
|
|
3041
|
+
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions);
|
|
3042
|
+
}
|
|
3043
|
+
async mkdir() {
|
|
3044
|
+
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions);
|
|
3045
|
+
}
|
|
3046
|
+
readdir() {
|
|
3047
|
+
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions);
|
|
3048
|
+
}
|
|
3049
|
+
async delete() {
|
|
3050
|
+
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions);
|
|
3051
|
+
}
|
|
3052
|
+
async rename() {
|
|
3053
|
+
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions);
|
|
2488
3054
|
}
|
|
2489
3055
|
}
|
|
2490
3056
|
const extensionFileSystemProvider = new ExtensionFileSystemProviderWithFileReadWriteCapability();
|
|
3057
|
+
class OverlayFileSystemProvider {
|
|
3058
|
+
constructor(_default) {
|
|
3059
|
+
this._default = _default;
|
|
3060
|
+
this.others = [];
|
|
3061
|
+
this.onDidChangeCapabilities = Event.any(...( this.delegates.map(delegate => delegate.onDidChangeCapabilities)));
|
|
3062
|
+
this._onDidChangeFile = new Emitter();
|
|
3063
|
+
this.onDidChangeFile = Event.any(this._default.onDidChangeFile, this._onDidChangeFile.event);
|
|
3064
|
+
this.capabilities = 2 | 1024 ;
|
|
3065
|
+
_default.onDidChangeFile((e) => {
|
|
3066
|
+
this._onDidChangeFile.fire(e);
|
|
3067
|
+
});
|
|
3068
|
+
}
|
|
3069
|
+
register(delegate) {
|
|
3070
|
+
this.others.push(delegate);
|
|
3071
|
+
const disposableStore = new DisposableStore();
|
|
3072
|
+
disposableStore.add(delegate.onDidChangeFile(e => {
|
|
3073
|
+
this._onDidChangeFile.fire(e);
|
|
3074
|
+
}));
|
|
3075
|
+
disposableStore.add({
|
|
3076
|
+
dispose: () => {
|
|
3077
|
+
const index = this.others.indexOf(delegate);
|
|
3078
|
+
if (index >= 0) {
|
|
3079
|
+
this.others.splice(index, 1);
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
});
|
|
3083
|
+
return disposableStore;
|
|
3084
|
+
}
|
|
3085
|
+
get delegates() {
|
|
3086
|
+
return [this._default, ...this.others];
|
|
3087
|
+
}
|
|
3088
|
+
async readFromDelegates(caller) {
|
|
3089
|
+
for (const delegate of this.delegates) {
|
|
3090
|
+
try {
|
|
3091
|
+
return await caller(delegate);
|
|
3092
|
+
}
|
|
3093
|
+
catch (err) {
|
|
3094
|
+
if (err instanceof FileSystemProviderError && err.code === FileSystemProviderErrorCode.FileNotFound) {
|
|
3095
|
+
continue;
|
|
3096
|
+
}
|
|
3097
|
+
throw err;
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
throw createFileSystemProviderError('No file system registered', FileSystemProviderErrorCode.FileNotFound);
|
|
3101
|
+
}
|
|
3102
|
+
async writeToDelegates(caller) {
|
|
3103
|
+
await Promise.all(( this.delegates.map(async (delegate) => {
|
|
3104
|
+
if (((delegate.capabilities & 2048) ) === 0) {
|
|
3105
|
+
await caller(delegate);
|
|
3106
|
+
}
|
|
3107
|
+
})));
|
|
3108
|
+
}
|
|
3109
|
+
async stat(resource) {
|
|
3110
|
+
return this.readFromDelegates(delegate => delegate.stat(resource));
|
|
3111
|
+
}
|
|
3112
|
+
async readFile(resource) {
|
|
3113
|
+
return this.readFromDelegates(delegate => delegate.readFile(resource));
|
|
3114
|
+
}
|
|
3115
|
+
async readdir(resource) {
|
|
3116
|
+
return this.readFromDelegates(delegate => delegate.readdir(resource));
|
|
3117
|
+
}
|
|
3118
|
+
watch(resource, opts) {
|
|
3119
|
+
const store = new DisposableStore();
|
|
3120
|
+
for (const delegate of this.delegates) {
|
|
3121
|
+
store.add(delegate.watch(resource, opts));
|
|
3122
|
+
}
|
|
3123
|
+
return store;
|
|
3124
|
+
}
|
|
3125
|
+
async writeFile(resource, content, opts) {
|
|
3126
|
+
await this.writeToDelegates(delegate => delegate.writeFile(resource, content, opts));
|
|
3127
|
+
}
|
|
3128
|
+
async mkdir(resource) {
|
|
3129
|
+
await this.writeToDelegates(delegate => delegate.mkdir(resource));
|
|
3130
|
+
}
|
|
3131
|
+
async delete(resource, opts) {
|
|
3132
|
+
await this.writeToDelegates(delegate => delegate.delete(resource, opts));
|
|
3133
|
+
}
|
|
3134
|
+
async rename(from, to, opts) {
|
|
3135
|
+
await this.writeToDelegates(delegate => delegate.rename(from, to, opts));
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
const fileSystemProvider = new OverlayFileSystemProvider(new InMemoryFileSystemProvider());
|
|
2491
3139
|
let MemoryFileService = class MemoryFileService extends FileService {
|
|
2492
3140
|
constructor(logService) {
|
|
2493
3141
|
super(logService);
|
|
2494
|
-
|
|
3142
|
+
const userMemoryFileSystem = new InMemoryFileSystemProvider();
|
|
3143
|
+
this.registerProvider('user', userMemoryFileSystem);
|
|
2495
3144
|
this.registerProvider('extension', extensionFileSystemProvider);
|
|
3145
|
+
this.registerProvider('cache', new InMemoryFileSystemProvider());
|
|
3146
|
+
this.registerProvider('logs', new InMemoryFileSystemProvider());
|
|
3147
|
+
this.registerProvider('file', fileSystemProvider);
|
|
2496
3148
|
}
|
|
2497
3149
|
};
|
|
2498
|
-
MemoryFileService =
|
|
3150
|
+
MemoryFileService = __decorate([
|
|
2499
3151
|
( __param(0, ILogService))
|
|
2500
|
-
], MemoryFileService)
|
|
2501
|
-
function registerExtensionFile(extensionLocation, path, getContent) {
|
|
2502
|
-
return extensionFileSystemProvider.registerFile(joinPath(extensionLocation, path), getContent);
|
|
2503
|
-
}
|
|
3152
|
+
], MemoryFileService);
|
|
2504
3153
|
function getServiceOverride() {
|
|
2505
3154
|
return {
|
|
2506
3155
|
[( IFileService.toString())]: new SyncDescriptor(MemoryFileService),
|
|
2507
|
-
[( IExtensionResourceLoaderService.toString())]: new SyncDescriptor(SimpleExtensionResourceLoaderService),
|
|
2508
3156
|
[( ITextFileService.toString())]: new SyncDescriptor(BrowserTextFileService)
|
|
2509
3157
|
};
|
|
2510
3158
|
}
|
|
2511
|
-
|
|
3159
|
+
function registerExtensionFile(extensionLocation, path, getContent) {
|
|
3160
|
+
return extensionFileSystemProvider.registerFile(joinPath(extensionLocation, path), getContent);
|
|
3161
|
+
}
|
|
3162
|
+
function registerFileSystemOverlay(provider) {
|
|
3163
|
+
return fileSystemProvider.register(provider);
|
|
3164
|
+
}
|
|
3165
|
+
export { FileSystemProviderError, FileSystemProviderErrorCode, SimpleTextFileSystemProvider, getServiceOverride as default, registerExtensionFile, registerFileSystemOverlay };
|