From 76e9e2be97d3a7201c2383c2f99f475d7ecf66df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Fri, 2 Feb 2024 14:50:03 +0100 Subject: [PATCH 1/5] refactor: split file in 2 instead of using complex logic to split the file during build --- scripts/vscode.patch | 598 ++++++++++++++++++++++++++++++++++ src/service-override/files.ts | 2 +- src/service-override/views.ts | 4 +- 3 files changed, 600 insertions(+), 4 deletions(-) diff --git a/scripts/vscode.patch b/scripts/vscode.patch index c401e834..6f2cd04d 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -3393,6 +3393,604 @@ index 92097d03ccc..16165c90c90 100644 } get repository(): string | undefined { +diff --git a/src/vs/workbench/contrib/files/browser/files.configuration.contribution.ts b/src/vs/workbench/contrib/files/browser/files.configuration.contribution.ts +new file mode 100644 +index 00000000000..37a4bbd32ce +--- /dev/null ++++ b/src/vs/workbench/contrib/files/browser/files.configuration.contribution.ts +@@ -0,0 +1,266 @@ ++/*--------------------------------------------------------------------------------------------- ++ * Copyright (c) Microsoft Corporation. All rights reserved. ++ * Licensed under the MIT License. See License.txt in the project root for license information. ++ *--------------------------------------------------------------------------------------------*/ ++ ++import { isNative, isWeb } from 'vs/base/common/platform'; ++import { editorConfigurationBaseNode } from 'vs/editor/common/config/editorConfigurationSchema'; ++import * as nls from 'vs/nls'; ++import { Extensions as ConfigurationExtensions, ConfigurationScope, IConfigurationPropertySchema, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; ++import { AutoSaveConfiguration, FILES_ASSOCIATIONS_CONFIG, FILES_EXCLUDE_CONFIG, FILES_READONLY_EXCLUDE_CONFIG, FILES_READONLY_FROM_PERMISSIONS_CONFIG, FILES_READONLY_INCLUDE_CONFIG, HotExitConfiguration } from 'vs/platform/files/common/files'; ++import { Registry } from 'vs/platform/registry/common/platform'; ++import { SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/encoding'; ++ ++// Configuration ++const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); ++ ++const hotExitConfiguration: IConfigurationPropertySchema = isNative ? ++ { ++ 'type': 'string', ++ 'scope': ConfigurationScope.APPLICATION, ++ 'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE], ++ 'default': HotExitConfiguration.ON_EXIT, ++ 'markdownEnumDescriptions': [ ++ nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'), ++ nls.localize('hotExit.onExit', '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...`'), ++ nls.localize('hotExit.onExitAndWindowClose', '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...`') ++ ], ++ 'markdownDescription': nls.localize('hotExit', "[Hot Exit](https://aka.ms/vscode-hot-exit) controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.", HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) ++ } : { ++ 'type': 'string', ++ 'scope': ConfigurationScope.APPLICATION, ++ 'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE], ++ 'default': HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE, ++ 'markdownEnumDescriptions': [ ++ nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'), ++ nls.localize('hotExit.onExitAndWindowCloseBrowser', 'Hot exit will be triggered when the browser quits or the window or tab is closed.') ++ ], ++ 'markdownDescription': nls.localize('hotExit', "[Hot Exit](https://aka.ms/vscode-hot-exit) controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.", HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) ++ }; ++ ++configurationRegistry.registerConfiguration({ ++ 'id': 'files', ++ 'order': 9, ++ 'title': nls.localize('filesConfigurationTitle', "Files"), ++ 'type': 'object', ++ 'properties': { ++ [FILES_EXCLUDE_CONFIG]: { ++ 'type': 'object', ++ 'markdownDescription': nls.localize('exclude', "Configure [glob patterns](https://aka.ms/vscode-glob-patterns) 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`."), ++ 'default': { ++ ...{ '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true, '**/Thumbs.db': true }, ++ ...(isWeb ? { '**/*.crswap': true /* filter out swap files used for local file access */ } : undefined) ++ }, ++ 'scope': ConfigurationScope.RESOURCE, ++ 'additionalProperties': { ++ 'anyOf': [ ++ { ++ 'type': 'boolean', ++ 'enum': [true, false], ++ 'enumDescriptions': [nls.localize('trueDescription', "Enable the pattern."), nls.localize('falseDescription', "Disable the pattern.")], ++ 'description': nls.localize('files.exclude.boolean', "The glob pattern to match file paths against. Set to true or false to enable or disable the pattern."), ++ }, ++ { ++ 'type': 'object', ++ 'properties': { ++ 'when': { ++ 'type': 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } }) ++ 'pattern': '\\w*\\$\\(basename\\)\\w*', ++ 'default': '$(basename).ext', ++ 'markdownDescription': nls.localize({ key: 'files.exclude.when', comment: ['\\$(basename) should not be translated'] }, "Additional check on the siblings of a matching file. Use \\$(basename) as variable for the matching file name.") ++ } ++ } ++ } ++ ] ++ } ++ }, ++ [FILES_ASSOCIATIONS_CONFIG]: { ++ 'type': 'object', ++ 'markdownDescription': nls.localize('associations', "Configure [glob patterns](https://aka.ms/vscode-glob-patterns) of file associations to languages (for example `\"*.extension\": \"html\"`). Patterns will match on the absolute path of a file if they contain a path separator and will match on the name of the file otherwise. These have precedence over the default associations of the languages installed."), ++ 'additionalProperties': { ++ 'type': 'string' ++ } ++ }, ++ 'files.encoding': { ++ 'type': 'string', ++ 'enum': Object.keys(SUPPORTED_ENCODINGS), ++ 'default': 'utf8', ++ 'description': nls.localize('encoding', "The default character set encoding to use when reading and writing files. This setting can also be configured per language."), ++ 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE, ++ 'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong), ++ 'enumItemLabels': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong) ++ }, ++ 'files.autoGuessEncoding': { ++ 'type': 'boolean', ++ 'default': false, ++ 'markdownDescription': nls.localize('autoGuessEncoding', "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.", '`#files.encoding#`'), ++ 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE ++ }, ++ 'files.eol': { ++ 'type': 'string', ++ 'enum': [ ++ '\n', ++ '\r\n', ++ 'auto' ++ ], ++ 'enumDescriptions': [ ++ nls.localize('eol.LF', "LF"), ++ nls.localize('eol.CRLF', "CRLF"), ++ nls.localize('eol.auto', "Uses operating system specific end of line character.") ++ ], ++ 'default': 'auto', ++ 'description': nls.localize('eol', "The default end of line character."), ++ 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE ++ }, ++ 'files.enableTrash': { ++ 'type': 'boolean', ++ 'default': true, ++ 'description': nls.localize('useTrash', "Moves files/folders to the OS trash (recycle bin on Windows) when deleting. Disabling this will delete files/folders permanently.") ++ }, ++ 'files.trimTrailingWhitespace': { ++ 'type': 'boolean', ++ 'default': false, ++ 'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."), ++ 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE ++ }, ++ 'files.insertFinalNewline': { ++ 'type': 'boolean', ++ 'default': false, ++ 'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."), ++ 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE ++ }, ++ 'files.trimFinalNewlines': { ++ 'type': 'boolean', ++ 'default': false, ++ 'description': nls.localize('trimFinalNewlines', "When enabled, will trim all new lines after the final new line at the end of the file when saving it."), ++ scope: ConfigurationScope.LANGUAGE_OVERRIDABLE, ++ }, ++ 'files.autoSave': { ++ 'type': 'string', ++ 'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE], ++ 'markdownEnumDescriptions': [ ++ nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.off' }, "An editor with changes is never automatically saved."), ++ nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.afterDelay' }, "An editor with changes is automatically saved after the configured `#files.autoSaveDelay#`."), ++ nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onFocusChange' }, "An editor with changes is automatically saved when the editor loses focus."), ++ nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onWindowChange' }, "An editor with changes is automatically saved when the window loses focus.") ++ ], ++ 'default': isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF, ++ 'markdownDescription': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSave' }, "Controls [auto save](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save) of editors that have unsaved changes.", AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE, AutoSaveConfiguration.AFTER_DELAY) ++ }, ++ 'files.autoSaveDelay': { ++ 'type': 'number', ++ 'default': 1000, ++ 'minimum': 0, ++ 'markdownDescription': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSaveDelay' }, "Controls the delay in milliseconds after which an editor with unsaved changes is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.", AutoSaveConfiguration.AFTER_DELAY) ++ }, ++ 'files.watcherExclude': { ++ 'type': 'object', ++ 'patternProperties': { ++ '.*': { 'type': 'boolean' } ++ }, ++ 'default': { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/node_modules/*/**': true, '**/.hg/store/**': true }, ++ 'markdownDescription': nls.localize('watcherExclude', "Configure paths or [glob patterns](https://aka.ms/vscode-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)."), ++ 'scope': ConfigurationScope.RESOURCE ++ }, ++ 'files.watcherInclude': { ++ 'type': 'array', ++ 'items': { ++ 'type': 'string' ++ }, ++ 'default': [], ++ 'description': nls.localize('watcherInclude', "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."), ++ 'scope': ConfigurationScope.RESOURCE ++ }, ++ 'files.hotExit': hotExitConfiguration, ++ 'files.defaultLanguage': { ++ 'type': 'string', ++ 'markdownDescription': nls.localize('defaultLanguage', "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.") ++ }, ++ [FILES_READONLY_INCLUDE_CONFIG]: { ++ 'type': 'object', ++ 'patternProperties': { ++ '.*': { 'type': 'boolean' } ++ }, ++ 'default': {}, ++ 'markdownDescription': nls.localize('filesReadonlyInclude', "Configure paths or [glob patterns](https://aka.ms/vscode-glob-patterns) to mark as read-only. Glob patterns are always evaluated relative to the path of the workspace folder unless they are absolute paths. You can exclude matching paths via the `#files.readonlyExclude#` setting. Files from readonly file system providers will always be read-only independent of this setting."), ++ 'scope': ConfigurationScope.RESOURCE ++ }, ++ [FILES_READONLY_EXCLUDE_CONFIG]: { ++ 'type': 'object', ++ 'patternProperties': { ++ '.*': { 'type': 'boolean' } ++ }, ++ 'default': {}, ++ 'markdownDescription': nls.localize('filesReadonlyExclude', "Configure paths or [glob patterns](https://aka.ms/vscode-glob-patterns) to exclude from being marked as read-only if they match as a result of the `#files.readonlyInclude#` setting. Glob patterns are always evaluated relative to the path of the workspace folder unless they are absolute paths. Files from readonly file system providers will always be read-only independent of this setting."), ++ 'scope': ConfigurationScope.RESOURCE ++ }, ++ [FILES_READONLY_FROM_PERMISSIONS_CONFIG]: { ++ 'type': 'boolean', ++ 'markdownDescription': nls.localize('filesReadonlyFromPermissions', "Marks files as read-only when their file permissions indicate as such. This can be overridden via `#files.readonlyInclude#` and `#files.readonlyExclude#` settings."), ++ 'default': false ++ }, ++ 'files.restoreUndoStack': { ++ 'type': 'boolean', ++ 'description': nls.localize('files.restoreUndoStack', "Restore the undo stack when a file is reopened."), ++ 'default': true ++ }, ++ 'files.saveConflictResolution': { ++ 'type': 'string', ++ 'enum': [ ++ 'askUser', ++ 'overwriteFileOnDisk' ++ ], ++ 'enumDescriptions': [ ++ nls.localize('askUser', "Will refuse to save and ask for resolving the save conflict manually."), ++ nls.localize('overwriteFileOnDisk', "Will resolve the save conflict by overwriting the file on disk with the changes in the editor.") ++ ], ++ 'description': nls.localize('files.saveConflictResolution', "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."), ++ 'default': 'askUser', ++ 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE ++ }, ++ 'files.dialog.defaultPath': { ++ 'type': 'string', ++ 'pattern': '^((\\/|\\\\\\\\|[a-zA-Z]:\\\\).*)?$', // slash OR UNC-root OR drive-root OR undefined ++ 'patternErrorMessage': nls.localize('defaultPathErrorMessage', "Default path for file dialogs must be an absolute path (e.g. C:\\\\myFolder or /myFolder)."), ++ 'description': nls.localize('fileDialogDefaultPath', "Default path for file dialogs, overriding user's home path. Only used in the absence of a context-specific path, such as most recently opened file or folder."), ++ 'scope': ConfigurationScope.MACHINE ++ }, ++ 'files.simpleDialog.enable': { ++ 'type': 'boolean', ++ 'description': nls.localize('files.simpleDialog.enable', "Enables the simple file dialog for opening and saving files and folders. The simple file dialog replaces the system file dialog when enabled."), ++ 'default': false ++ }, ++ 'files.participants.timeout': { ++ type: 'number', ++ default: 60000, ++ markdownDescription: nls.localize('files.participants.timeout', "Timeout in milliseconds after which file participants for create, rename, and delete are cancelled. Use `0` to disable participants."), ++ } ++ } ++}); ++ ++configurationRegistry.registerConfiguration({ ++ ...editorConfigurationBaseNode, ++ properties: { ++ 'editor.formatOnSave': { ++ 'type': 'boolean', ++ 'description': nls.localize('formatOnSave', "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."), ++ 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE, ++ }, ++ 'editor.formatOnSaveMode': { ++ 'type': 'string', ++ 'default': 'file', ++ 'enum': [ ++ 'file', ++ 'modifications', ++ 'modificationsIfAvailable' ++ ], ++ 'enumDescriptions': [ ++ nls.localize({ key: 'everything', comment: ['This is the description of an option'] }, "Format the whole file."), ++ nls.localize({ key: 'modification', comment: ['This is the description of an option'] }, "Format modifications (requires source control)."), ++ nls.localize({ key: 'modificationIfAvailable', comment: ['This is the description of an option'] }, "Will attempt to format modifications only (requires source control). If source control can't be used, then the whole file will be formatted."), ++ ], ++ 'markdownDescription': nls.localize('formatOnSaveMode', "Controls if format on save formats the whole file or only modifications. Only applies when `#editor.formatOnSave#` is enabled."), ++ 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE, ++ }, ++ } ++}); +diff --git a/src/vs/workbench/contrib/files/browser/files.contribution.ts b/src/vs/workbench/contrib/files/browser/files.contribution.ts +index 985ef683fce..d89f4aa9d16 100644 +--- a/src/vs/workbench/contrib/files/browser/files.contribution.ts ++++ b/src/vs/workbench/contrib/files/browser/files.contribution.ts +@@ -3,39 +3,37 @@ + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +-import * as nls from 'vs/nls'; ++import { Schemas } from 'vs/base/common/network'; + import { sep } from 'vs/base/common/path'; ++import { isWindows } from 'vs/base/common/platform'; ++import { RedoCommand, UndoCommand } from 'vs/editor/browser/editorExtensions'; ++import { ModesRegistry } from 'vs/editor/common/languages/modesRegistry'; ++import * as nls from 'vs/nls'; ++import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; ++import { Extensions as ConfigurationExtensions, ConfigurationScope, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; ++import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; ++import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; ++import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; ++import { ILabelService } from 'vs/platform/label/common/label'; + import { Registry } from 'vs/platform/registry/common/platform'; +-import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope, IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry'; +-import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions'; +-import { IFileEditorInput, IEditorFactoryRegistry, EditorExtensions } from 'vs/workbench/common/editor'; +-import { AutoSaveConfiguration, HotExitConfiguration, FILES_EXCLUDE_CONFIG, FILES_ASSOCIATIONS_CONFIG, FILES_READONLY_INCLUDE_CONFIG, FILES_READONLY_EXCLUDE_CONFIG, FILES_READONLY_FROM_PERMISSIONS_CONFIG } from 'vs/platform/files/common/files'; +-import { SortOrder, LexicographicOptions, FILE_EDITOR_INPUT_ID, BINARY_TEXT_FILE_MODE, UndoConfirmLevel, IFilesConfiguration } from 'vs/workbench/contrib/files/common/files'; ++import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo'; ++import { EditorPaneDescriptor, IEditorPaneRegistry } from 'vs/workbench/browser/editor'; ++import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; ++import { EditorExtensions, IEditorFactoryRegistry, IFileEditorInput } from 'vs/workbench/common/editor'; ++import { BinaryFileEditor } from 'vs/workbench/contrib/files/browser/editors/binaryFileEditor'; ++import { FileEditorInputSerializer, FileEditorWorkingCopyEditorHandler } from 'vs/workbench/contrib/files/browser/editors/fileEditorHandler'; ++import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput'; ++import { TextFileEditor } from 'vs/workbench/contrib/files/browser/editors/textFileEditor'; + import { TextFileEditorTracker } from 'vs/workbench/contrib/files/browser/editors/textFileEditorTracker'; + import { TextFileSaveErrorHandler } from 'vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler'; +-import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput'; +-import { BinaryFileEditor } from 'vs/workbench/contrib/files/browser/editors/binaryFileEditor'; +-import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; +-import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; +-import { isNative, isWeb, isWindows } from 'vs/base/common/platform'; +-import { ExplorerViewletViewsContribution } from 'vs/workbench/contrib/files/browser/explorerViewlet'; +-import { IEditorPaneRegistry, EditorPaneDescriptor } from 'vs/workbench/browser/editor'; +-import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; +-import { ILabelService } from 'vs/platform/label/common/label'; +-import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; + import { ExplorerService, UNDO_REDO_SOURCE } from 'vs/workbench/contrib/files/browser/explorerService'; +-import { SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/encoding'; +-import { Schemas } from 'vs/base/common/network'; ++import { ExplorerViewletViewsContribution } from 'vs/workbench/contrib/files/browser/explorerViewlet'; ++import { IExplorerService } from 'vs/workbench/contrib/files/browser/files'; + import { WorkspaceWatcher } from 'vs/workbench/contrib/files/browser/workspaceWatcher'; +-import { editorConfigurationBaseNode } from 'vs/editor/common/config/editorConfigurationSchema'; + import { DirtyFilesIndicator } from 'vs/workbench/contrib/files/common/dirtyFilesIndicator'; +-import { UndoCommand, RedoCommand } from 'vs/editor/browser/editorExtensions'; +-import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo'; +-import { IExplorerService } from 'vs/workbench/contrib/files/browser/files'; +-import { FileEditorInputSerializer, FileEditorWorkingCopyEditorHandler } from 'vs/workbench/contrib/files/browser/editors/fileEditorHandler'; +-import { ModesRegistry } from 'vs/editor/common/languages/modesRegistry'; +-import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +-import { TextFileEditor } from 'vs/workbench/contrib/files/browser/editors/textFileEditor'; ++import { BINARY_TEXT_FILE_MODE, FILE_EDITOR_INPUT_ID, IFilesConfiguration, LexicographicOptions, SortOrder, UndoConfirmLevel } from 'vs/workbench/contrib/files/common/files'; ++import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; ++import './files.configuration.contribution'; + + class FileUriLabelContribution implements IWorkbenchContribution { + +@@ -119,257 +117,6 @@ Registry.as(WorkbenchExtensions.Workbench).regi + // Configuration + const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); + +-const hotExitConfiguration: IConfigurationPropertySchema = isNative ? +- { +- 'type': 'string', +- 'scope': ConfigurationScope.APPLICATION, +- 'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE], +- 'default': HotExitConfiguration.ON_EXIT, +- 'markdownEnumDescriptions': [ +- nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'), +- nls.localize('hotExit.onExit', '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...`'), +- nls.localize('hotExit.onExitAndWindowClose', '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...`') +- ], +- 'markdownDescription': nls.localize('hotExit', "[Hot Exit](https://aka.ms/vscode-hot-exit) controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.", HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) +- } : { +- 'type': 'string', +- 'scope': ConfigurationScope.APPLICATION, +- 'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE], +- 'default': HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE, +- 'markdownEnumDescriptions': [ +- nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'), +- nls.localize('hotExit.onExitAndWindowCloseBrowser', 'Hot exit will be triggered when the browser quits or the window or tab is closed.') +- ], +- 'markdownDescription': nls.localize('hotExit', "[Hot Exit](https://aka.ms/vscode-hot-exit) controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.", HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) +- }; +- +-configurationRegistry.registerConfiguration({ +- 'id': 'files', +- 'order': 9, +- 'title': nls.localize('filesConfigurationTitle', "Files"), +- 'type': 'object', +- 'properties': { +- [FILES_EXCLUDE_CONFIG]: { +- 'type': 'object', +- 'markdownDescription': nls.localize('exclude', "Configure [glob patterns](https://aka.ms/vscode-glob-patterns) 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`."), +- 'default': { +- ...{ '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true, '**/Thumbs.db': true }, +- ...(isWeb ? { '**/*.crswap': true /* filter out swap files used for local file access */ } : undefined) +- }, +- 'scope': ConfigurationScope.RESOURCE, +- 'additionalProperties': { +- 'anyOf': [ +- { +- 'type': 'boolean', +- 'enum': [true, false], +- 'enumDescriptions': [nls.localize('trueDescription', "Enable the pattern."), nls.localize('falseDescription', "Disable the pattern.")], +- 'description': nls.localize('files.exclude.boolean', "The glob pattern to match file paths against. Set to true or false to enable or disable the pattern."), +- }, +- { +- 'type': 'object', +- 'properties': { +- 'when': { +- 'type': 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } }) +- 'pattern': '\\w*\\$\\(basename\\)\\w*', +- 'default': '$(basename).ext', +- 'markdownDescription': nls.localize({ key: 'files.exclude.when', comment: ['\\$(basename) should not be translated'] }, "Additional check on the siblings of a matching file. Use \\$(basename) as variable for the matching file name.") +- } +- } +- } +- ] +- } +- }, +- [FILES_ASSOCIATIONS_CONFIG]: { +- 'type': 'object', +- 'markdownDescription': nls.localize('associations', "Configure [glob patterns](https://aka.ms/vscode-glob-patterns) of file associations to languages (for example `\"*.extension\": \"html\"`). Patterns will match on the absolute path of a file if they contain a path separator and will match on the name of the file otherwise. These have precedence over the default associations of the languages installed."), +- 'additionalProperties': { +- 'type': 'string' +- } +- }, +- 'files.encoding': { +- 'type': 'string', +- 'enum': Object.keys(SUPPORTED_ENCODINGS), +- 'default': 'utf8', +- 'description': nls.localize('encoding', "The default character set encoding to use when reading and writing files. This setting can also be configured per language."), +- 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE, +- 'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong), +- 'enumItemLabels': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong) +- }, +- 'files.autoGuessEncoding': { +- 'type': 'boolean', +- 'default': false, +- 'markdownDescription': nls.localize('autoGuessEncoding', "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.", '`#files.encoding#`'), +- 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE +- }, +- 'files.eol': { +- 'type': 'string', +- 'enum': [ +- '\n', +- '\r\n', +- 'auto' +- ], +- 'enumDescriptions': [ +- nls.localize('eol.LF', "LF"), +- nls.localize('eol.CRLF', "CRLF"), +- nls.localize('eol.auto', "Uses operating system specific end of line character.") +- ], +- 'default': 'auto', +- 'description': nls.localize('eol', "The default end of line character."), +- 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE +- }, +- 'files.enableTrash': { +- 'type': 'boolean', +- 'default': true, +- 'description': nls.localize('useTrash', "Moves files/folders to the OS trash (recycle bin on Windows) when deleting. Disabling this will delete files/folders permanently.") +- }, +- 'files.trimTrailingWhitespace': { +- 'type': 'boolean', +- 'default': false, +- 'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."), +- 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE +- }, +- 'files.insertFinalNewline': { +- 'type': 'boolean', +- 'default': false, +- 'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."), +- 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE +- }, +- 'files.trimFinalNewlines': { +- 'type': 'boolean', +- 'default': false, +- 'description': nls.localize('trimFinalNewlines', "When enabled, will trim all new lines after the final new line at the end of the file when saving it."), +- scope: ConfigurationScope.LANGUAGE_OVERRIDABLE, +- }, +- 'files.autoSave': { +- 'type': 'string', +- 'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE], +- 'markdownEnumDescriptions': [ +- nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.off' }, "An editor with changes is never automatically saved."), +- nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.afterDelay' }, "An editor with changes is automatically saved after the configured `#files.autoSaveDelay#`."), +- nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onFocusChange' }, "An editor with changes is automatically saved when the editor loses focus."), +- nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onWindowChange' }, "An editor with changes is automatically saved when the window loses focus.") +- ], +- 'default': isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF, +- 'markdownDescription': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSave' }, "Controls [auto save](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save) of editors that have unsaved changes.", AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE, AutoSaveConfiguration.AFTER_DELAY) +- }, +- 'files.autoSaveDelay': { +- 'type': 'number', +- 'default': 1000, +- 'minimum': 0, +- 'markdownDescription': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSaveDelay' }, "Controls the delay in milliseconds after which an editor with unsaved changes is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.", AutoSaveConfiguration.AFTER_DELAY) +- }, +- 'files.watcherExclude': { +- 'type': 'object', +- 'patternProperties': { +- '.*': { 'type': 'boolean' } +- }, +- 'default': { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/node_modules/*/**': true, '**/.hg/store/**': true }, +- 'markdownDescription': nls.localize('watcherExclude', "Configure paths or [glob patterns](https://aka.ms/vscode-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)."), +- 'scope': ConfigurationScope.RESOURCE +- }, +- 'files.watcherInclude': { +- 'type': 'array', +- 'items': { +- 'type': 'string' +- }, +- 'default': [], +- 'description': nls.localize('watcherInclude', "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."), +- 'scope': ConfigurationScope.RESOURCE +- }, +- 'files.hotExit': hotExitConfiguration, +- 'files.defaultLanguage': { +- 'type': 'string', +- 'markdownDescription': nls.localize('defaultLanguage', "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.") +- }, +- [FILES_READONLY_INCLUDE_CONFIG]: { +- 'type': 'object', +- 'patternProperties': { +- '.*': { 'type': 'boolean' } +- }, +- 'default': {}, +- 'markdownDescription': nls.localize('filesReadonlyInclude', "Configure paths or [glob patterns](https://aka.ms/vscode-glob-patterns) to mark as read-only. Glob patterns are always evaluated relative to the path of the workspace folder unless they are absolute paths. You can exclude matching paths via the `#files.readonlyExclude#` setting. Files from readonly file system providers will always be read-only independent of this setting."), +- 'scope': ConfigurationScope.RESOURCE +- }, +- [FILES_READONLY_EXCLUDE_CONFIG]: { +- 'type': 'object', +- 'patternProperties': { +- '.*': { 'type': 'boolean' } +- }, +- 'default': {}, +- 'markdownDescription': nls.localize('filesReadonlyExclude', "Configure paths or [glob patterns](https://aka.ms/vscode-glob-patterns) to exclude from being marked as read-only if they match as a result of the `#files.readonlyInclude#` setting. Glob patterns are always evaluated relative to the path of the workspace folder unless they are absolute paths. Files from readonly file system providers will always be read-only independent of this setting."), +- 'scope': ConfigurationScope.RESOURCE +- }, +- [FILES_READONLY_FROM_PERMISSIONS_CONFIG]: { +- 'type': 'boolean', +- 'markdownDescription': nls.localize('filesReadonlyFromPermissions', "Marks files as read-only when their file permissions indicate as such. This can be overridden via `#files.readonlyInclude#` and `#files.readonlyExclude#` settings."), +- 'default': false +- }, +- 'files.restoreUndoStack': { +- 'type': 'boolean', +- 'description': nls.localize('files.restoreUndoStack', "Restore the undo stack when a file is reopened."), +- 'default': true +- }, +- 'files.saveConflictResolution': { +- 'type': 'string', +- 'enum': [ +- 'askUser', +- 'overwriteFileOnDisk' +- ], +- 'enumDescriptions': [ +- nls.localize('askUser', "Will refuse to save and ask for resolving the save conflict manually."), +- nls.localize('overwriteFileOnDisk', "Will resolve the save conflict by overwriting the file on disk with the changes in the editor.") +- ], +- 'description': nls.localize('files.saveConflictResolution', "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."), +- 'default': 'askUser', +- 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE +- }, +- 'files.dialog.defaultPath': { +- 'type': 'string', +- 'pattern': '^((\\/|\\\\\\\\|[a-zA-Z]:\\\\).*)?$', // slash OR UNC-root OR drive-root OR undefined +- 'patternErrorMessage': nls.localize('defaultPathErrorMessage', "Default path for file dialogs must be an absolute path (e.g. C:\\\\myFolder or /myFolder)."), +- 'description': nls.localize('fileDialogDefaultPath', "Default path for file dialogs, overriding user's home path. Only used in the absence of a context-specific path, such as most recently opened file or folder."), +- 'scope': ConfigurationScope.MACHINE +- }, +- 'files.simpleDialog.enable': { +- 'type': 'boolean', +- 'description': nls.localize('files.simpleDialog.enable', "Enables the simple file dialog for opening and saving files and folders. The simple file dialog replaces the system file dialog when enabled."), +- 'default': false +- }, +- 'files.participants.timeout': { +- type: 'number', +- default: 60000, +- markdownDescription: nls.localize('files.participants.timeout', "Timeout in milliseconds after which file participants for create, rename, and delete are cancelled. Use `0` to disable participants."), +- } +- } +-}); +- +-configurationRegistry.registerConfiguration({ +- ...editorConfigurationBaseNode, +- properties: { +- 'editor.formatOnSave': { +- 'type': 'boolean', +- 'description': nls.localize('formatOnSave', "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."), +- 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE, +- }, +- 'editor.formatOnSaveMode': { +- 'type': 'string', +- 'default': 'file', +- 'enum': [ +- 'file', +- 'modifications', +- 'modificationsIfAvailable' +- ], +- 'enumDescriptions': [ +- nls.localize({ key: 'everything', comment: ['This is the description of an option'] }, "Format the whole file."), +- nls.localize({ key: 'modification', comment: ['This is the description of an option'] }, "Format modifications (requires source control)."), +- nls.localize({ key: 'modificationIfAvailable', comment: ['This is the description of an option'] }, "Will attempt to format modifications only (requires source control). If source control can't be used, then the whole file will be formatted."), +- ], +- 'markdownDescription': nls.localize('formatOnSaveMode', "Controls if format on save formats the whole file or only modifications. Only applies when `#editor.formatOnSave#` is enabled."), +- 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE, +- }, +- } +-}); +- + configurationRegistry.registerConfiguration({ + 'id': 'explorer', + 'order': 10, diff --git a/src/vs/workbench/contrib/search/browser/searchModel.ts b/src/vs/workbench/contrib/search/browser/searchModel.ts index 82b4121cf6a..8b6803f2396 100644 --- a/src/vs/workbench/contrib/search/browser/searchModel.ts diff --git a/src/service-override/files.ts b/src/service-override/files.ts index f019b8e3..ddd7496d 100644 --- a/src/service-override/files.ts +++ b/src/service-override/files.ts @@ -11,7 +11,7 @@ import { extUri, joinPath } from 'vs/base/common/resources' import { Emitter, Event } from 'vs/base/common/event' import { HTMLFileSystemProvider } from 'vs/platform/files/browser/htmlFileSystemProvider' import * as path from 'vs/base/common/path' -import 'vs/workbench/contrib/files/browser/files.contribution.js?include=registerConfiguration' +import 'vs/workbench/contrib/files/browser/files.configuration.contribution' import { Schemas } from 'vs/base/common/network' import { IndexedDBFileSystemProvider, IndexedDBFileSystemProviderErrorData, IndexedDBFileSystemProviderErrorDataClassification } from 'vs/platform/files/browser/indexedDBFileSystemProvider' import { IndexedDB } from 'vs/base/browser/indexedDB' diff --git a/src/service-override/views.ts b/src/service-override/views.ts index 246a38b5..c24b737e 100644 --- a/src/service-override/views.ts +++ b/src/service-override/views.ts @@ -37,9 +37,7 @@ import 'vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribu import 'vs/workbench/contrib/languageStatus/browser/languageStatus.contribution' import 'vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution' import 'vs/workbench/contrib/webview/browser/webview.contribution' -// import to 2 times with filter to not duplicate the import from files.ts -import 'vs/workbench/contrib/files/browser/files.contribution.js?include=registerConfiguration' -import 'vs/workbench/contrib/files/browser/files.contribution.js?exclude=registerConfiguration' +import 'vs/workbench/contrib/files/browser/files.contribution' import { Codicon } from 'vs/base/common/codicons' import { GroupOrientation, GroupsOrder, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' import { IEditorService } from 'vs/workbench/services/editor/common/editorService' From a42dcdf987581f85adac84c005e2890c0cf34ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Fri, 2 Feb 2024 14:50:27 +0100 Subject: [PATCH 2/5] cleanup: remove complex logic to split file at build time --- rollup/rollup.config.ts | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/rollup/rollup.config.ts b/rollup/rollup.config.ts index 66c8bc90..06cd502a 100644 --- a/rollup/rollup.config.ts +++ b/rollup/rollup.config.ts @@ -271,12 +271,7 @@ function isCallPure (file: string, functionName: string, node: recast.types.name return PURE_OR_TO_REMOVE_FUNCTIONS.has(functionName) } -interface TreeShakeOptions { - include: string[] - exclude: string[] -} - -function transformVSCodeCode (id: string, code: string, options: TreeShakeOptions) { +function transformVSCodeCode (id: string, code: string) { // HACK: assign typescript decorator result to a decorated class field so rollup doesn't remove them // before: // __decorate([ @@ -330,11 +325,11 @@ function transformVSCodeCode (id: string, code: string, options: TreeShakeOption if (name != null) { names.unshift(name) } - if (options.include.length > 0 ? !names.some(name => options.include.includes(name)) : (names.some(name => isCallPure(id, name, node) || options.exclude.includes(name)))) { + if (names.some(name => isCallPure(id, name, node))) { path.replace(addComment(node)) } } - } else if (node.callee.type === 'Identifier' && (options.include.length > 0 ? !options.include.includes(node.callee.name) : (isCallPure(id, node.callee.name, node) || options.exclude.includes(node.callee.name)))) { + } else if (node.callee.type === 'Identifier' && isCallPure(id, node.callee.name, node)) { path.replace(addComment(node)) } else if (node.callee.type === 'FunctionExpression') { const lastInstruction = node.callee.body.body[node.callee.body.body.length - 1] @@ -519,7 +514,6 @@ export default (args: Record): rollup.RollupOptions[] => { path.endsWith('xtensionPoint.js') || path.includes('vs/workbench/api/browser/') || path.endsWith('/fileCommands.js') || - path.endsWith('/explorerViewlet.js') || path.endsWith('/listCommands.js') || path.endsWith('/quickAccessActions.js') || path.endsWith('/gotoLineQuickAccess.js') || @@ -581,18 +575,12 @@ export default (args: Record): rollup.RollupOptions[] => { if (!id.startsWith(VSCODE_SRC_DIR)) { return undefined } - const [, path, query] = /^(.*?)(\?.*?)?$/.exec(id)! - if (!path!.endsWith('.js')) { + if (!id.endsWith('.js')) { return undefined } - const searchParams = new URLSearchParams(query) - const options: TreeShakeOptions = { - include: searchParams.getAll('include'), - exclude: searchParams.getAll('exclude') - } - const content = (await fsPromise.readFile(path!)).toString('utf-8') - return transformVSCodeCode(path!, content, options) + const content = (await fsPromise.readFile(id)).toString('utf-8') + return transformVSCodeCode(id, content) }, transform (code) { return code.replaceAll("'./keyboardLayouts/layout.contribution.' + platform", "'./keyboardLayouts/layout.contribution.' + platform + '.js'") From ac3f828bd4b1f496925f144fba87ad5a1d45093a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Fri, 2 Feb 2024 14:51:25 +0100 Subject: [PATCH 3/5] fix: only import autosave from editor service override --- scripts/vscode.patch | 45 ++++++++++++++++++++++++++++++++++ src/service-override/editor.ts | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/scripts/vscode.patch b/scripts/vscode.patch index 6f2cd04d..7b995fcb 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -2771,6 +2771,51 @@ index a2007e18299..7446cfcfc5f 100644 ? compositeSwitcherBar.getHeight(currentItemsLength + index) : compositeSwitcherBar.getWidth(currentItemsLength + index) )); +diff --git a/src/vs/workbench/browser/parts/editor/editor.autosave.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.autosave.contribution.ts +new file mode 100644 +index 00000000000..aa99110545a +--- /dev/null ++++ b/src/vs/workbench/browser/parts/editor/editor.autosave.contribution.ts +@@ -0,0 +1,11 @@ ++/*--------------------------------------------------------------------------------------------- ++ * Copyright (c) Microsoft Corporation. All rights reserved. ++ * Licensed under the MIT License. See License.txt in the project root for license information. ++ *--------------------------------------------------------------------------------------------*/ ++ ++import { Registry } from 'vs/platform/registry/common/platform'; ++import { EditorAutoSave } from 'vs/workbench/browser/parts/editor/editorAutoSave'; ++import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; ++import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; ++ ++Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EditorAutoSave, LifecyclePhase.Ready); +diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts +index ac6ace35f03..a04cb0f5ad1 100644 +--- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts ++++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts +@@ -57,7 +57,6 @@ import { EditorContributionInstantiation, registerEditorContribution } from 'vs/ + import { FloatingEditorClickMenu } from 'vs/workbench/browser/codeeditor'; + import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions'; + import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; +-import { EditorAutoSave } from 'vs/workbench/browser/parts/editor/editorAutoSave'; + import { IQuickAccessRegistry, Extensions as QuickAccessExtensions } from 'vs/platform/quickinput/common/quickAccess'; + import { ActiveGroupEditorsByMostRecentlyUsedQuickAccess, AllEditorsByAppearanceQuickAccess, AllEditorsByMostRecentlyUsedQuickAccess } from 'vs/workbench/browser/parts/editor/editorQuickAccess'; + import { FileAccess } from 'vs/base/common/network'; +@@ -68,6 +67,7 @@ import { DynamicEditorConfigurations } from 'vs/workbench/browser/parts/editor/e + import { EditorActionsDefaultAction, EditorActionsTitleBarAction, HideEditorActionsAction, HideEditorTabsAction, ShowMultipleEditorTabsAction, ShowSingleEditorTabAction } from 'vs/workbench/browser/actions/layoutActions'; + import { ICommandAction } from 'vs/platform/action/common/action'; + import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; ++import './editor.autosave.contribution'; + + //#region Editor Registrations + +@@ -124,7 +124,6 @@ Registry.as(EditorExtensions.EditorFactory).registerEdit + + //#region Workbench Contributions + +-Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EditorAutoSave, LifecyclePhase.Ready); + Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EditorStatusContribution, LifecyclePhase.Ready); + Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(UntitledTextEditorWorkingCopyEditorHandler, LifecyclePhase.Ready); + Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DynamicEditorConfigurations, LifecyclePhase.Ready); diff --git a/src/vs/workbench/browser/parts/editor/editorGroupWatermark.ts b/src/vs/workbench/browser/parts/editor/editorGroupWatermark.ts index 3c4ac7d594b..e942fbd2e40 100644 --- a/src/vs/workbench/browser/parts/editor/editorGroupWatermark.ts diff --git a/src/service-override/editor.ts b/src/service-override/editor.ts index 037d13fe..76bf8471 100644 --- a/src/service-override/editor.ts +++ b/src/service-override/editor.ts @@ -17,7 +17,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' import { DEFAULT_EDITOR_PART_OPTIONS, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor' import { MonacoDelegateEditorGroupsService, MonacoEditorService, OpenEditor } from './tools/editor' import { unsupported } from '../tools' -import 'vs/workbench/browser/parts/editor/editor.contribution' +import 'vs/workbench/browser/parts/editor/editor.autosave.contribution' class EmptyEditorGroup implements IEditorGroup, IEditorGroupView { get groupsView () { From 01112d1daaa7e5610bcad47ad262ba9741f44eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Fri, 2 Feb 2024 14:51:43 +0100 Subject: [PATCH 4/5] fix: backport VSCode fix --- scripts/vscode.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/vscode.patch b/scripts/vscode.patch index 7b995fcb..f064aa5a 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -4642,6 +4642,19 @@ index fb13ac6c764..f8c6873926c 100644 this._cachedResolver = new KeybindingResolver(defaults, overrides, (str) => this._log(str)); } return this._cachedResolver; +diff --git a/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts b/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts +index c55684f0424..bb50e96ff77 100644 +--- a/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts ++++ b/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts +@@ -396,7 +396,7 @@ export class BrowserKeyboardMapperFactoryBase extends Disposable { + private async _getBrowserKeyMapping(keyboardEvent?: IKeyboardEvent): Promise { + if ((navigator as any).keyboard) { + try { +- return (navigator as any).keyboard.getLayoutMap().then((e: any) => { ++ return await (navigator as any).keyboard.getLayoutMap().then((e: any) => { + const ret: IKeyboardMapping = {}; + for (const key of e) { + ret[key[0]] = { diff --git a/src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.ts b/src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.ts index e8c8239b35f..9017a971ee5 100644 --- a/src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.ts From dc074dbe7823712b439e0efa392059191f0f5516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Fri, 2 Feb 2024 19:40:57 +0100 Subject: [PATCH 5/5] fix: split another file to be able to import both editor and views service override without crashing --- scripts/vscode.patch | 59 +++++++++++++++++++++++++++++++--- src/service-override/editor.ts | 14 +------- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/scripts/vscode.patch b/scripts/vscode.patch index f064aa5a..0cca68d2 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -3711,10 +3711,10 @@ index 00000000000..37a4bbd32ce + } +}); diff --git a/src/vs/workbench/contrib/files/browser/files.contribution.ts b/src/vs/workbench/contrib/files/browser/files.contribution.ts -index 985ef683fce..d89f4aa9d16 100644 +index 985ef683fce..689f25c1926 100644 --- a/src/vs/workbench/contrib/files/browser/files.contribution.ts +++ b/src/vs/workbench/contrib/files/browser/files.contribution.ts -@@ -3,39 +3,37 @@ +@@ -3,39 +3,38 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ @@ -3740,7 +3740,7 @@ index 985ef683fce..d89f4aa9d16 100644 +import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo'; +import { EditorPaneDescriptor, IEditorPaneRegistry } from 'vs/workbench/browser/editor'; +import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; -+import { EditorExtensions, IEditorFactoryRegistry, IFileEditorInput } from 'vs/workbench/common/editor'; ++import { EditorExtensions, IEditorFactoryRegistry } from 'vs/workbench/common/editor'; +import { BinaryFileEditor } from 'vs/workbench/contrib/files/browser/editors/binaryFileEditor'; +import { FileEditorInputSerializer, FileEditorWorkingCopyEditorHandler } from 'vs/workbench/contrib/files/browser/editors/fileEditorHandler'; +import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput'; @@ -3775,10 +3775,32 @@ index 985ef683fce..d89f4aa9d16 100644 +import { BINARY_TEXT_FILE_MODE, FILE_EDITOR_INPUT_ID, IFilesConfiguration, LexicographicOptions, SortOrder, UndoConfirmLevel } from 'vs/workbench/contrib/files/common/files'; +import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; +import './files.configuration.contribution'; ++import './files.fileEditorFactory.contribution'; class FileUriLabelContribution implements IWorkbenchContribution { -@@ -119,257 +117,6 @@ Registry.as(WorkbenchExtensions.Workbench).regi +@@ -80,20 +79,6 @@ Registry.as(EditorExtensions.EditorPane).registerEditorPane + ] + ); + +-// Register default file input factory +-Registry.as(EditorExtensions.EditorFactory).registerFileEditorFactory({ +- +- typeId: FILE_EDITOR_INPUT_ID, +- +- createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService): IFileEditorInput => { +- return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents); +- }, +- +- isFileEditor: (obj): obj is IFileEditorInput => { +- return obj instanceof FileEditorInput; +- } +-}); +- + // Register Editor Input Serializer & Handler + Registry.as(EditorExtensions.EditorFactory).registerEditorSerializer(FILE_EDITOR_INPUT_ID, FileEditorInputSerializer); + Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(FileEditorWorkingCopyEditorHandler, LifecyclePhase.Ready); +@@ -119,257 +104,6 @@ Registry.as(WorkbenchExtensions.Workbench).regi // Configuration const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); @@ -4036,6 +4058,35 @@ index 985ef683fce..d89f4aa9d16 100644 configurationRegistry.registerConfiguration({ 'id': 'explorer', 'order': 10, +diff --git a/src/vs/workbench/contrib/files/browser/files.fileEditorFactory.contribution.ts b/src/vs/workbench/contrib/files/browser/files.fileEditorFactory.contribution.ts +new file mode 100644 +index 00000000000..2f31d6a7984 +--- /dev/null ++++ b/src/vs/workbench/contrib/files/browser/files.fileEditorFactory.contribution.ts +@@ -0,0 +1,23 @@ ++/*--------------------------------------------------------------------------------------------- ++ * Copyright (c) Microsoft Corporation. All rights reserved. ++ * Licensed under the MIT License. See License.txt in the project root for license information. ++ *--------------------------------------------------------------------------------------------*/ ++ ++import { Registry } from 'vs/platform/registry/common/platform'; ++import { EditorExtensions, IEditorFactoryRegistry, IFileEditorInput } from 'vs/workbench/common/editor'; ++import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput'; ++import { FILE_EDITOR_INPUT_ID } from 'vs/workbench/contrib/files/common/files'; ++ ++// Register default file input factory ++Registry.as(EditorExtensions.EditorFactory).registerFileEditorFactory({ ++ ++ typeId: FILE_EDITOR_INPUT_ID, ++ ++ createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService): IFileEditorInput => { ++ return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents); ++ }, ++ ++ isFileEditor: (obj): obj is IFileEditorInput => { ++ return obj instanceof FileEditorInput; ++ } ++}); diff --git a/src/vs/workbench/contrib/search/browser/searchModel.ts b/src/vs/workbench/contrib/search/browser/searchModel.ts index 82b4121cf6a..8b6803f2396 100644 --- a/src/vs/workbench/contrib/search/browser/searchModel.ts diff --git a/src/service-override/editor.ts b/src/service-override/editor.ts index 76bf8471..fda0ff49 100644 --- a/src/service-override/editor.ts +++ b/src/service-override/editor.ts @@ -4,13 +4,10 @@ import { IResolvedTextEditorModel } from 'vs/editor/common/services/resolverServ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' import { CodeEditorService } from 'vs/workbench/services/editor/browser/codeEditorService' import { IEditorService } from 'vs/workbench/services/editor/common/editorService' -import { EditorExtensions, IEditorFactoryRegistry, IFileEditorInput } from 'vs/workbench/common/editor' import { IEditorOptions } from 'vs/platform/editor/common/editor' import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors' import { IReference } from 'vs/base/common/lifecycle' import { ITextEditorService, TextEditorService } from 'vs/workbench/services/textfile/common/textEditorService' -import { Registry } from 'vs/platform/registry/common/platform' -import { FILE_EDITOR_INPUT_ID } from 'vs/workbench/contrib/files/common/files' import { GroupOrientation, IEditorGroup, IEditorGroupsService, IEditorPart } from 'vs/workbench/services/editor/common/editorGroupsService' import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' @@ -18,6 +15,7 @@ import { DEFAULT_EDITOR_PART_OPTIONS, IEditorGroupView } from 'vs/workbench/brow import { MonacoDelegateEditorGroupsService, MonacoEditorService, OpenEditor } from './tools/editor' import { unsupported } from '../tools' import 'vs/workbench/browser/parts/editor/editor.autosave.contribution' +import 'vs/workbench/contrib/files/browser/files.fileEditorFactory.contribution' class EmptyEditorGroup implements IEditorGroup, IEditorGroupView { get groupsView () { @@ -217,16 +215,6 @@ class MonacoEditorGroupsService extends MonacoDelegateEditorGroupsService(EditorExtensions.EditorFactory).registerFileEditorFactory({ - typeId: FILE_EDITOR_INPUT_ID, - createFileEditor: unsupported, - isFileEditor: (obj): obj is IFileEditorInput => false -}) - export default function getServiceOverride (openEditor: OpenEditor): IEditorOverrideServices { return { [ICodeEditorService.toString()]: new SyncDescriptor(CodeEditorService, undefined, true),