From 8c597c4e2394d1fcf918b97a7116c7797c033d93 Mon Sep 17 00:00:00 2001 From: wolfsilver Date: Sat, 8 Jul 2023 00:19:57 +0800 Subject: [PATCH 1/3] chore: bump vscode to 1.80.0 --- vscode-web/.VERSION | 2 +- .../vs/editor/common/config/editorOptions.ts | 171 ++++++++++++++++-- .../parts/activitybar/activitybarPart.ts | 4 +- .../src/vs/workbench/browser/web.main.ts | 71 +++++--- .../files/browser/editors/fileEditorInput.ts | 27 ++- .../contrib/webview/browser/pre/index.html | 2 +- .../textfile/browser/textFileService.ts | 6 +- 7 files changed, 226 insertions(+), 57 deletions(-) diff --git a/vscode-web/.VERSION b/vscode-web/.VERSION index 1aa8d83eb..ec09153a6 100644 --- a/vscode-web/.VERSION +++ b/vscode-web/.VERSION @@ -1 +1 @@ -1.78.2 \ No newline at end of file +1.80.0 \ No newline at end of file diff --git a/vscode-web/src/vs/editor/common/config/editorOptions.ts b/vscode-web/src/vs/editor/common/config/editorOptions.ts index 41a24ab1e..97a34371d 100644 --- a/vscode-web/src/vs/editor/common/config/editorOptions.ts +++ b/vscode-web/src/vs/editor/common/config/editorOptions.ts @@ -3,19 +3,20 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as nls from 'vs/nls'; +import * as arrays from 'vs/base/common/arrays'; +import { IMarkdownString } from 'vs/base/common/htmlContent'; +import { IJSONSchema } from 'vs/base/common/jsonSchema'; +import * as objects from 'vs/base/common/objects'; import * as platform from 'vs/base/common/platform'; import { ScrollbarVisibility } from 'vs/base/common/scrollable'; -import { FontInfo } from 'vs/editor/common/config/fontInfo'; import { Constants } from 'vs/base/common/uint'; +import { FontInfo } from 'vs/editor/common/config/fontInfo'; +import { EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/core/textModelDefaults'; import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/core/wordHelper'; +import { IDocumentDiffProvider } from 'vs/editor/common/diff/documentDiffProvider'; +import * as nls from 'vs/nls'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; import { IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry'; -import { IJSONSchema } from 'vs/base/common/jsonSchema'; -import * as arrays from 'vs/base/common/arrays'; -import * as objects from 'vs/base/common/objects'; -import { EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/core/textModelDefaults'; -import { IDocumentDiffProvider } from 'vs/editor/common/diff/documentDiffProvider'; //#region typed options @@ -151,6 +152,10 @@ export interface IEditorOptions { * Defaults to false. */ readOnly?: boolean; + /** + * The message to display when the editor is readonly. + */ + readOnlyMessage?: IMarkdownString; /** * Should the textarea used for input use the DOM `readonly` attribute. * Defaults to false. @@ -349,6 +354,10 @@ export interface IEditorOptions { * Enable inline color decorators and color picker rendering. */ colorDecorators?: boolean; + /** + * Controls what is the condition to spawn a color picker from a color dectorator + */ + colorDecoratorsActivatedOn?: 'clickAndHover' | 'click' | 'hover'; /** * Controls the max number of color decorators that can be rendered in an editor at once. */ @@ -707,6 +716,11 @@ export interface IEditorOptions { */ dropIntoEditor?: IDropIntoEditorOptions; + /** + * Controls support for changing how content is pasted into the editor. + */ + pasteAs?: IPasteAsOptions; + /** * Controls whether the editor receives tabs or defers them to the workbench for navigation. */ @@ -789,6 +803,25 @@ export interface IDiffEditorBaseOptions { * Whether the diff editor aria label should be verbose. */ accessibilityVerbose?: boolean; + + experimental?: { + /** + * Defaults to false. + */ + collapseUnchangedRegions?: boolean; + /** + * Defaults to false. + */ + showMoves?: boolean; + + showEmptyDecorations?: boolean; + }; + + /** + * Is the diff editor inside another editor + * Defaults to false + */ + isInEmbeddedEditor?: boolean; } /** @@ -3434,6 +3467,30 @@ class EditorRulers extends BaseEditorOption { + constructor() { + const defaults = undefined; + + super( + EditorOption.readOnlyMessage, 'readOnlyMessage', defaults + ); + } + + public validate(_input: any): IMarkdownString | undefined { + if (!_input || typeof _input !== 'object') { + return this.defaultValue; + } + return _input as IMarkdownString; + } +} + +//#endregion + //#region scrollbar /** @@ -4282,7 +4339,7 @@ class EditorSuggest extends BaseEditorOption>; + +class EditorPasteAs extends BaseEditorOption { + + constructor() { + const defaults: EditorPasteAsOptions = { enabled: true, showPasteSelector: 'afterPaste' }; + super( + EditorOption.pasteAs, 'pasteAs', defaults, + { + 'editor.pasteAs.enabled': { + type: 'boolean', + default: defaults.enabled, + markdownDescription: nls.localize('pasteAs.enabled', "Controls whether you can paste content in different ways."), + }, + 'editor.pasteAs.showPasteSelector': { + type: 'string', + markdownDescription: nls.localize('pasteAs.showPasteSelector', "Controls if a widget is shown when pasting content in to the editor. This widget lets you control how the file is pasted."), + enum: [ + 'afterPaste', + 'never' + ], + enumDescriptions: [ + nls.localize('pasteAs.showPasteSelector.afterPaste', "Show the paste selector widget after content is pasted into the editor."), + nls.localize('pasteAs.showPasteSelector.never', "Never show the paste selector widget. Instead the default pasting behavior is always used."), + ], + default: 'afterPaste', + }, + } + ); + } + + public validate(_input: any): EditorPasteAsOptions { + if (!_input || typeof _input !== 'object') { + return this.defaultValue; + } + const input = _input as IPasteAsOptions; + return { + enabled: boolean(input.enabled, this.defaultValue.enabled), + showPasteSelector: stringSet(input.showPasteSelector, this.defaultValue.showPasteSelector, ['afterPaste', 'never']), + }; + } +} + +//#endregion + const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace'; const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace'; const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace'; @@ -4917,12 +5049,14 @@ export const enum EditorOption { overviewRulerBorder, overviewRulerLanes, padding, + pasteAs, parameterHints, peekWidgetDefaultFocus, definitionLinkOpensInPeek, quickSuggestions, quickSuggestionsDelay, readOnly, + readOnlyMessage, renameOnType, renderControlCharacters, renderFinalNewline, @@ -4977,7 +5111,8 @@ export const enum EditorOption { tabFocusMode, layoutInfo, wrappingInfo, - defaultColorDecorators + defaultColorDecorators, + colorDecoratorsActivatedOn } export const EditorOptions = { @@ -5008,9 +5143,9 @@ export const EditorOptions = { EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content") )), screenReaderAnnounceInlineSuggestion: register(new EditorBooleanOption( - EditorOption.screenReaderAnnounceInlineSuggestion, 'screenReaderAnnounceInlineSuggestion', false, + EditorOption.screenReaderAnnounceInlineSuggestion, 'screenReaderAnnounceInlineSuggestion', true, { - description: nls.localize('screenReaderAnnounceInlineSuggestion', "Control whether inline suggestions are announced by a screen reader. Note that this does not work on macOS with VoiceOver."), + description: nls.localize('screenReaderAnnounceInlineSuggestion', "Control whether inline suggestions are announced by a screen reader."), tags: ['accessibility'] } )), @@ -5126,6 +5261,14 @@ export const EditorOptions = { EditorOption.colorDecorators, 'colorDecorators', true, { description: nls.localize('colorDecorators', "Controls whether the editor should render the inline color decorators and color picker.") } )), + colorDecoratorActivatedOn: register(new EditorStringEnumOption(EditorOption.colorDecoratorsActivatedOn, 'colorDecoratorsActivatedOn', 'clickAndHover' as 'clickAndHover' | 'hover' | 'click', ['clickAndHover', 'hover', 'click'] as const, { + enumDescriptions: [ + nls.localize('editor.colorDecoratorActivatedOn.clickAndHover', "Make the color picker appear both on click and hover of the color decorator"), + nls.localize('editor.colorDecoratorActivatedOn.hover', "Make the color picker appear on hover of the color decorator"), + nls.localize('editor.colorDecoratorActivatedOn.click', "Make the color picker appear on click of the color decorator") + ], + description: nls.localize('colorDecoratorActivatedOn', "Controls the condition to make a color picker appear from a color decorator") + })), colorDecoratorsLimit: register(new EditorIntOption( EditorOption.colorDecoratorsLimit, 'colorDecoratorsLimit', 500, 1, 1000000, { @@ -5395,6 +5538,7 @@ export const EditorOptions = { 3, 0, 3 )), padding: register(new EditorPadding()), + pasteAs: register(new EditorPasteAs()), parameterHints: register(new EditorParameterHints()), peekWidgetDefaultFocus: register(new EditorStringEnumOption( EditorOption.peekWidgetDefaultFocus, 'peekWidgetDefaultFocus', @@ -5421,6 +5565,7 @@ export const EditorOptions = { readOnly: register(new EditorBooleanOption( EditorOption.readOnly, 'readOnly', false, )), + readOnlyMessage: register(new ReadonlyMessage()), renameOnType: register(new EditorBooleanOption( EditorOption.renameOnType, 'renameOnType', false, { description: nls.localize('renameOnType', "Controls whether the editor auto renames on type."), markdownDeprecationMessage: nls.localize('renameOnTypeDeprecate', "Deprecated, use `editor.linkedEditing` instead.") } diff --git a/vscode-web/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts b/vscode-web/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts index 869ae6b03..b41bca013 100644 --- a/vscode-web/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts +++ b/vscode-web/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts @@ -921,7 +921,7 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart state.push({ id: compositeItem.id, name: viewContainerModel.title, - icon: URI.isUri(viewContainerModel.icon) && this.environmentService.remoteAuthority ? undefined : viewContainerModel.icon, /* Donot cache uri icons with remote connection */ + icon: URI.isUri(viewContainerModel.icon) && this.environmentService.remoteAuthority ? undefined : viewContainerModel.icon, // Do not cache uri icons with remote connection views, pinned: compositeItem.pinned, order: compositeItem.order, @@ -947,7 +947,7 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart cachedViewContainer.icon = placeholderViewContainer.themeIcon ? placeholderViewContainer.themeIcon : placeholderViewContainer.iconUrl ? URI.revive(placeholderViewContainer.iconUrl) : undefined; if (URI.isUri(cachedViewContainer.icon) && this.environmentService.remoteAuthority) { - cachedViewContainer.icon = undefined; /* Donot cache uri icons with remote connection */ + cachedViewContainer.icon = undefined; // Do not cache uri icons with remote connection } cachedViewContainer.views = placeholderViewContainer.views; cachedViewContainer.isBuiltin = placeholderViewContainer.isBuiltin; diff --git a/vscode-web/src/vs/workbench/browser/web.main.ts b/vscode-web/src/vs/workbench/browser/web.main.ts index a98c22a2c..93087c084 100644 --- a/vscode-web/src/vs/workbench/browser/web.main.ts +++ b/vscode-web/src/vs/workbench/browser/web.main.ts @@ -18,7 +18,7 @@ import { IProductService } from 'vs/platform/product/common/productService'; import product from 'vs/platform/product/common/product'; import { RemoteAgentService } from 'vs/workbench/services/remote/browser/remoteAgentService'; import { RemoteAuthorityResolverService } from 'vs/platform/remote/browser/remoteAuthorityResolverService'; -import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver'; +import { IRemoteAuthorityResolverService, RemoteConnectionType } from 'vs/platform/remote/common/remoteAuthorityResolver'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; import { IWorkbenchFileService } from 'vs/workbench/services/files/common/files'; import { FileService } from 'vs/platform/files/common/fileService'; @@ -35,8 +35,6 @@ import { SignService } from 'vs/platform/sign/browser/signService'; import { IWorkbenchConstructionOptions, IWorkbench, ITunnel } from 'vs/workbench/browser/web.api'; import { BrowserStorageService } from 'vs/workbench/services/storage/browser/storageService'; import { IStorageService } from 'vs/platform/storage/common/storage'; -import { BufferLogger } from 'vs/platform/log/common/bufferLog'; -import { FileLoggerService } from 'vs/platform/log/common/fileLog'; import { toLocalISOString } from 'vs/base/common/date'; import { isWorkspaceToOpen, isFolderToOpen } from 'vs/platform/window/common/window'; import { getSingleFolderWorkspaceIdentifier, getWorkspaceIdentifier } from 'vs/workbench/services/workspaces/browser/workspaces'; @@ -84,10 +82,16 @@ import { BrowserUserDataProfilesService } from 'vs/platform/userDataProfile/brow import { timeout } from 'vs/base/common/async'; import { windowLogId } from 'vs/workbench/services/log/common/logConstants'; import { LogService } from 'vs/platform/log/common/logService'; +import { IRemoteSocketFactoryService, RemoteSocketFactoryService } from 'vs/platform/remote/common/remoteSocketFactoryService'; +import { BrowserSocketFactory } from 'vs/platform/remote/browser/browserSocketFactory'; import { VSBuffer } from 'vs/base/common/buffer'; import { IStoredWorkspace } from 'vs/platform/workspaces/common/workspaces'; import { UserDataProfileInitializer } from 'vs/workbench/services/userDataProfile/browser/userDataProfileInit'; import { UserDataSyncInitializer } from 'vs/workbench/services/userDataSync/browser/userDataSyncInit'; +import { BrowserRemoteResourceLoader } from 'vs/workbench/services/remote/browser/browserRemoteResourceHandler'; +import { BufferLogger } from 'vs/platform/log/common/bufferLog'; +import { FileLoggerService } from 'vs/platform/log/common/fileLog'; +import { IEmbedderTerminalService } from 'vs/workbench/services/terminal/common/embedderTerminalService'; export class BrowserMain extends Disposable { @@ -148,6 +152,7 @@ export class BrowserMain extends Disposable { const instantiationService = accessor.get(IInstantiationService); const remoteExplorerService = accessor.get(IRemoteExplorerService); const labelService = accessor.get(ILabelService); + const embedderTerminalService = accessor.get(IEmbedderTerminalService); let logger: DelayedLogChannel | undefined = undefined; @@ -178,7 +183,8 @@ export class BrowserMain extends Disposable { } }, window: { - withProgress: (options, task) => progressService.withProgress(options, task) + withProgress: (options, task) => progressService.withProgress(options, task), + createTerminal: (options) => embedderTerminalService.createTerminal(options), }, workspace: { openTunnel: async tunnelOptions => { @@ -245,23 +251,41 @@ export class BrowserMain extends Disposable { const environmentService = new BrowserWorkbenchEnvironmentService(workspace.id, logsPath, this.configuration, productService); serviceCollection.set(IBrowserWorkbenchEnvironmentService, environmentService); - // Log - const logLevel = getLogLevel(environmentService); - const bufferLogger = new BufferLogger(logLevel); - const otherLoggers: ILogger[] = [new ConsoleLogger(logLevel)]; + // Files + const fileLogger = new BufferLogger(); + const fileService = this._register(new FileService(fileLogger)); + serviceCollection.set(IWorkbenchFileService, fileService); + + // Logger + const loggerService = new FileLoggerService(getLogLevel(environmentService), logsPath, fileService); + serviceCollection.set(ILoggerService, loggerService); + + // Log Service + const otherLoggers: ILogger[] = [new ConsoleLogger(loggerService.getLogLevel())]; if (environmentService.isExtensionDevelopment && !!environmentService.extensionTestsLocationURI) { - otherLoggers.push(new ConsoleLogInAutomationLogger(logLevel)); + otherLoggers.push(new ConsoleLogInAutomationLogger(loggerService.getLogLevel())); } - const logService = new LogService(bufferLogger, otherLoggers); + const logger = loggerService.createLogger(environmentService.logFile, { id: windowLogId, name: localize('rendererLog', "Window") }); + const logService = new LogService(logger, otherLoggers); serviceCollection.set(ILogService, logService); + // Set the logger of the fileLogger after the log service is ready. + // This is to avoid cyclic dependency + fileLogger.logger = logService; + + // Register File System Providers depending on IndexedDB support + // Register them early because they are needed for the profiles initialization + await this.registerIndexedDBFileSystemProviders(environmentService, fileService, logService, loggerService, logsPath); + // Remote const connectionToken = environmentService.options.connectionToken || getCookieValue(connectionTokenCookieName); - const remoteAuthorityResolverService = new RemoteAuthorityResolverService(connectionToken, this.configuration.resourceUriProvider, productService, logService); + const remoteResourceLoader = this.configuration.remoteResourceProvider ? new BrowserRemoteResourceLoader(fileService, this.configuration.remoteResourceProvider) : undefined; + const resourceUriProvider = this.configuration.resourceUriProvider ?? remoteResourceLoader?.getResourceUriProvider(); + const remoteAuthorityResolverService = new RemoteAuthorityResolverService(!environmentService.expectsResolverExtension, connectionToken, resourceUriProvider, productService, logService); serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService); // Signing - const signService = new SignService(connectionToken); + const signService = new SignService(productService); serviceCollection.set(ISignService, signService); @@ -275,18 +299,6 @@ export class BrowserMain extends Disposable { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Files - const fileService = this._register(new FileService(logService)); - serviceCollection.set(IWorkbenchFileService, fileService); - - // Logger - const loggerService = new FileLoggerService(logLevel, logsPath, fileService); - serviceCollection.set(ILoggerService, loggerService); - - // Register File System Providers depending on IndexedDB support - // Register them early because they are needed for the profiles initialization - await this.registerIndexedDBFileSystemProviders(environmentService, fileService, bufferLogger, logService, loggerService, logsPath); - // URI Identity const uriIdentityService = new UriIdentityService(fileService); serviceCollection.set(IUriIdentityService, uriIdentityService); @@ -300,7 +312,10 @@ export class BrowserMain extends Disposable { serviceCollection.set(IUserDataProfileService, userDataProfileService); // Remote Agent - const remoteAgentService = this._register(new RemoteAgentService(this.configuration.webSocketFactory, userDataProfileService, environmentService, productService, remoteAuthorityResolverService, signService, logService)); + const remoteSocketFactoryService = new RemoteSocketFactoryService(); + remoteSocketFactoryService.register(RemoteConnectionType.WebSocket, new BrowserSocketFactory(this.configuration.webSocketFactory)); + serviceCollection.set(IRemoteSocketFactoryService, remoteSocketFactoryService); + const remoteAgentService = this._register(new RemoteAgentService(remoteSocketFactoryService, userDataProfileService, environmentService, productService, remoteAuthorityResolverService, signService, logService)); serviceCollection.set(IRemoteAgentService, remoteAgentService); this._register(RemoteFileSystemProviderClient.register(remoteAgentService, fileService, logService)); @@ -406,7 +421,7 @@ export class BrowserMain extends Disposable { } } - private async registerIndexedDBFileSystemProviders(environmentService: IWorkbenchEnvironmentService, fileService: IWorkbenchFileService, bufferLogger: BufferLogger, logService: ILogService, loggerService: ILoggerService, logsPath: URI): Promise { + private async registerIndexedDBFileSystemProviders(environmentService: IWorkbenchEnvironmentService, fileService: IWorkbenchFileService, logService: ILogService, loggerService: ILoggerService, logsPath: URI): Promise { // IndexedDB is used for logging and user data let indexedDB: IndexedDB | undefined; const userDataStore = 'vscode-userdata-store'; @@ -430,8 +445,6 @@ export class BrowserMain extends Disposable { fileService.registerProvider(logsPath.scheme, new InMemoryFileSystemProvider()); } - bufferLogger.logger = loggerService.createLogger(environmentService.logFile, { id: windowLogId, name: localize('rendererLog', "Window") }); - // User data let userDataProvider; if (indexedDB) { @@ -514,7 +527,7 @@ export class BrowserMain extends Disposable { } } - private async createWorkspaceService(workspace: IAnyWorkspaceIdentifier, environmentService: IWorkbenchEnvironmentService, userDataProfileService: IUserDataProfileService, userDataProfilesService: IUserDataProfilesService, fileService: FileService, remoteAgentService: IRemoteAgentService, uriIdentityService: IUriIdentityService, logService: ILogService): Promise { + private async createWorkspaceService(workspace: IAnyWorkspaceIdentifier, environmentService: IBrowserWorkbenchEnvironmentService, userDataProfileService: IUserDataProfileService, userDataProfilesService: IUserDataProfilesService, fileService: FileService, remoteAgentService: IRemoteAgentService, uriIdentityService: IUriIdentityService, logService: ILogService): Promise { // Temporary workspaces do not exist on startup because they are // just in memory. As such, detect this case and eagerly create diff --git a/vscode-web/src/vs/workbench/contrib/files/browser/editors/fileEditorInput.ts b/vscode-web/src/vs/workbench/contrib/files/browser/editors/fileEditorInput.ts index b486a7873..4326f0472 100644 --- a/vscode-web/src/vs/workbench/contrib/files/browser/editors/fileEditorInput.ts +++ b/vscode-web/src/vs/workbench/contrib/files/browser/editors/fileEditorInput.ts @@ -9,7 +9,7 @@ import { EditorInput } from 'vs/workbench/common/editor/editorInput'; import { AbstractTextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput'; import { ITextResourceEditorInput } from 'vs/platform/editor/common/editor'; import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel'; -import { ByteSize, FileSystemProviderCapabilities, IFileReadLimits, IFileService, getLargeFileConfirmationLimit } from 'vs/platform/files/common/files'; +import { ByteSize, IFileReadLimits, IFileService, getLargeFileConfirmationLimit } from 'vs/platform/files/common/files'; import { ITextFileService, TextFileEditorModelState, TextFileResolveReason, TextFileOperationError, TextFileOperationResult, ITextFileEditorModel, EncodingMode } from 'vs/workbench/services/textfile/common/textfiles'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IReference, dispose, DisposableStore } from 'vs/base/common/lifecycle'; @@ -24,6 +24,8 @@ import { Schemas } from 'vs/base/common/network'; import { createTextBufferFactory } from 'vs/editor/common/model/textModel'; import { IPathService } from 'vs/workbench/services/path/common/pathService'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfiguration'; +import { isConfigured } from 'vs/platform/configuration/common/configuration'; +import { IMarkdownString } from 'vs/base/common/htmlContent'; const enum ForceOpenAs { None, @@ -53,7 +55,7 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements } } else { if (this.fileService.hasProvider(this.resource)) { - if (this.fileService.hasCapability(this.resource, FileSystemProviderCapabilities.Readonly)) { + if (this.filesConfigurationService.isReadonly(this.resource)) { capabilities |= EditorInputCapabilities.Readonly; } } else { @@ -94,12 +96,12 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements @ITextModelService private readonly textModelResolverService: ITextModelService, @ILabelService labelService: ILabelService, @IFileService fileService: IFileService, - @IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService, + @IFilesConfigurationService filesConfigurationService: IFilesConfigurationService, @IEditorService editorService: IEditorService, @IPathService private readonly pathService: IPathService, @ITextResourceConfigurationService private readonly textResourceConfigurationService: ITextResourceConfigurationService ) { - super(resource, preferredResource, editorService, textFileService, labelService, fileService); + super(resource, preferredResource, editorService, textFileService, labelService, fileService, filesConfigurationService); this.model = this.textFileService.files.get(resource); @@ -194,6 +196,10 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements return this.preferredName; } + override isReadonly(): boolean | IMarkdownString { + return this.model ? this.model.isReadonly() : this.filesConfigurationService.isReadonly(this.resource); + } + override getDescription(verbosity?: Verbosity): string | undefined { return this.preferredDescription || super.getDescription(verbosity); } @@ -375,16 +381,21 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements return options.limits; // respect passed in limits if any } + // We want to determine the large file configuration based on the best defaults + // for the resource but also respecting user settings. We only apply user settings + // if explicitly configured by the user. Otherwise we pick the best limit for the + // resource scheme. + const defaultSizeLimit = getLargeFileConfirmationLimit(this.resource); let configuredSizeLimit: number | undefined = undefined; - const configuredSizeLimitMb = this.textResourceConfigurationService.getValue(this.resource, 'workbench.editorLargeFileConfirmation'); - if (typeof configuredSizeLimitMb === 'number') { - configuredSizeLimit = configuredSizeLimitMb * ByteSize.MB; // normalize to MB + const configuredSizeLimitMb = this.textResourceConfigurationService.inspect(this.resource, null, 'workbench.editorLargeFileConfirmation'); + if (isConfigured(configuredSizeLimitMb)) { + configuredSizeLimit = configuredSizeLimitMb.value * ByteSize.MB; // normalize to MB } return { - size: Math.max(defaultSizeLimit, configuredSizeLimit ?? defaultSizeLimit) // pick the highest limit + size: configuredSizeLimit ?? defaultSizeLimit }; } diff --git a/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html b/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html index 66b9c89b1..06bd919ee 100644 --- a/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html +++ b/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html @@ -5,7 +5,7 @@ + content="default-src 'none'; script-src 'sha256-7Y08cqii1UgeZbSST9r8UPSownOSMa3/PiKe77avh7I=' 'self'; frame-src 'self'; style-src 'unsafe-inline';"> Date: Sat, 8 Jul 2023 12:55:58 +0800 Subject: [PATCH 2/3] revert index.html --- .../src/vs/workbench/contrib/webview/browser/pre/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html b/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html index 06bd919ee..31719b66d 100644 --- a/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html +++ b/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html @@ -5,7 +5,7 @@ + content="default-src 'none'; script-src 'unsafe-inline' 'self'; frame-src 'self'; style-src 'unsafe-inline' 'self'; img-src 'self' https: data:; media-src 'self' https: data:; font-src 'self' https: data:;"> Date: Sat, 8 Jul 2023 12:58:00 +0800 Subject: [PATCH 3/3] format --- .../src/vs/workbench/contrib/webview/browser/pre/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html b/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html index 31719b66d..66b9c89b1 100644 --- a/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html +++ b/vscode-web/src/vs/workbench/contrib/webview/browser/pre/index.html @@ -5,7 +5,7 @@ + content="default-src 'none'; script-src 'unsafe-inline' 'self'; frame-src 'self'; style-src 'unsafe-inline' 'self'; img-src 'self' https: data:; media-src 'self' https: data:; font-src 'self' https: data:;">