diff --git a/src/vs/workbench/parts/preferences/common/preferencesContribution.ts b/src/vs/workbench/parts/preferences/common/preferencesContribution.ts index a5adc6ab4b79405d110f3f975d4e50d8a379bf3a..f1c464e54c53a24d4b694dde14322f4cb3fdf6ff 100644 --- a/src/vs/workbench/parts/preferences/common/preferencesContribution.ts +++ b/src/vs/workbench/parts/preferences/common/preferencesContribution.ts @@ -23,8 +23,8 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' import { IEditorInput } from 'vs/workbench/common/editor'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { isEqual } from 'vs/base/common/paths'; import { isLinux } from 'vs/base/common/platform'; +import { isEqual, hasToIgnoreCase } from 'vs/base/common/resources'; const schemaRegistry = Registry.as(JSONContributionRegistry.Extensions.JSONContribution); @@ -66,14 +66,14 @@ export class PreferencesContribution implements IWorkbenchContribution { private onEditorOpening(editor: IEditorInput, options: IEditorOptions | ITextEditorOptions, group: IEditorGroup): IOpenEditorOverride { const resource = editor.getResource(); if ( - !resource || resource.scheme !== 'file' || // require a file path opening - !endsWith(resource.fsPath, 'settings.json') || // file must end in settings.json + !resource || + !endsWith(resource.path, 'settings.json') || // resource must end in settings.json !this.configurationService.getValue(DEFAULT_SETTINGS_EDITOR_SETTING) // user has not disabled default settings editor ) { return void 0; } - // If the file resource was already opened before in the group, do not prevent + // If the resource was already opened before in the group, do not prevent // the opening of that resource. Otherwise we would have the same settings // opened twice (https://github.com/Microsoft/vscode/issues/36447) if (group.isOpened(editor)) { @@ -81,7 +81,7 @@ export class PreferencesContribution implements IWorkbenchContribution { } // Global User Settings File - if (isEqual(resource.fsPath, this.environmentService.appSettingsPath, !isLinux)) { + if (isEqual(resource, URI.file(this.environmentService.appSettingsPath), !isLinux)) { return { override: this.preferencesService.openGlobalSettings(options, group) }; } @@ -89,7 +89,7 @@ export class PreferencesContribution implements IWorkbenchContribution { const state = this.workspaceService.getWorkbenchState(); if (state === WorkbenchState.FOLDER) { const folders = this.workspaceService.getWorkspace().folders; - if (resource.fsPath === folders[0].toResource(FOLDER_SETTINGS_PATH).fsPath) { + if (isEqual(resource, folders[0].toResource(FOLDER_SETTINGS_PATH), hasToIgnoreCase(resource))) { return { override: this.preferencesService.openWorkspaceSettings(options, group) }; } } @@ -98,7 +98,7 @@ export class PreferencesContribution implements IWorkbenchContribution { else if (state === WorkbenchState.WORKSPACE) { const folders = this.workspaceService.getWorkspace().folders; for (let i = 0; i < folders.length; i++) { - if (resource.fsPath === folders[i].toResource(FOLDER_SETTINGS_PATH).fsPath) { + if (isEqual(resource, folders[i].toResource(FOLDER_SETTINGS_PATH), hasToIgnoreCase(resource))) { return { override: this.preferencesService.openFolderSettings(folders[i].uri, options, group) }; } } diff --git a/src/vs/workbench/parts/stats/node/workspaceStats.ts b/src/vs/workbench/parts/stats/node/workspaceStats.ts index 60b4979fd472076ac22bd4afc959f663abc5b77f..19bc5120d596089c551711e192a717eb7c5ca7cc 100644 --- a/src/vs/workbench/parts/stats/node/workspaceStats.ts +++ b/src/vs/workbench/parts/stats/node/workspaceStats.ts @@ -16,6 +16,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' import { IWindowConfiguration, IWindowService } from 'vs/platform/windows/common/windows'; import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { endsWith } from 'vs/base/common/strings'; +import { Schemas } from 'vs/base/common/network'; const SshProtocolMatcher = /^([^@:]+@)?([^:]+):/; const SshUrlMatcher = /^([^@:]+@)?([^:]+):(.+)$/; @@ -240,7 +241,8 @@ export class WorkspaceStats implements IWorkbenchContribution { workspaceId = void 0; break; case WorkbenchState.FOLDER: - workspaceId = crypto.createHash('sha1').update(workspace.folders[0].uri.fsPath).digest('hex'); + // TODO: #54483 @Ben + workspaceId = crypto.createHash('sha1').update(workspace.folders[0].uri.scheme === Schemas.file ? workspace.folders[0].uri.fsPath : workspace.folders[0].uri.toString()).digest('hex'); break; case WorkbenchState.WORKSPACE: workspaceId = crypto.createHash('sha1').update(workspace.configuration.fsPath).digest('hex'); diff --git a/src/vs/workbench/services/files/node/watcher/win32/watcherService.ts b/src/vs/workbench/services/files/node/watcher/win32/watcherService.ts index 26295cbc4a9d233977905f2f672f841263f11069..3672cdd0775b369d4c39a925fd75ed7c4ea3b21a 100644 --- a/src/vs/workbench/services/files/node/watcher/win32/watcherService.ts +++ b/src/vs/workbench/services/files/node/watcher/win32/watcherService.ts @@ -12,6 +12,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace import { normalize } from 'path'; import { rtrim, endsWith } from 'vs/base/common/strings'; import { sep } from 'vs/base/common/paths'; +import { Schemas } from 'vs/base/common/network'; export class FileWatcher { private isDisposed: boolean; @@ -26,6 +27,9 @@ export class FileWatcher { } public startWatching(): () => void { + if (this.contextService.getWorkspace().folders[0].uri.scheme !== Schemas.file) { + return () => { }; + } let basePath: string = normalize(this.contextService.getWorkspace().folders[0].uri.fsPath); if (basePath && basePath.indexOf('\\\\') === 0 && endsWith(basePath, sep)) { diff --git a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts index 78fa340fb7d87ded3e8e79a988bc02b88b4bb7f6..dbf27ba83f8c3abfcdf7aea71a85b475f559bffc 100644 --- a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts +++ b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts @@ -33,6 +33,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati import { isLinux } from 'vs/base/common/platform'; import { IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { ILogService } from 'vs/platform/log/common/log'; +import { isEqual, isEqualOrParent, hasToIgnoreCase } from 'vs/base/common/resources'; /** * The text file editor model listens to changes to its underlying code editor model and saves these changes through the file service back to the disk. @@ -778,13 +779,13 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil } // Check for global settings file - if (path.isEqual(this.resource.fsPath, this.environmentService.appSettingsPath, !isLinux)) { + if (isEqual(this.resource, URI.file(this.environmentService.appSettingsPath), !isLinux)) { return true; } // Check for workspace settings file return this.contextService.getWorkspace().folders.some(folder => { - return path.isEqualOrParent(this.resource.fsPath, path.join(folder.uri.fsPath, '.vscode')); + return isEqualOrParent(this.resource, folder.toResource('.vscode'), hasToIgnoreCase(this.resource)); }); } diff --git a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts b/src/vs/workbench/services/workspace/node/workspaceEditingService.ts index a7f6644ac3451a906c07bf1b049d4669e3171df1..6caf2e400a484f813cfd4cced0f3e50eeeeada5a 100644 --- a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts +++ b/src/vs/workbench/services/workspace/node/workspaceEditingService.ts @@ -26,7 +26,7 @@ import { BackupFileService } from 'vs/workbench/services/backup/node/backupFileS import { ICommandService } from 'vs/platform/commands/common/commands'; import { distinct } from 'vs/base/common/arrays'; import { isLinux } from 'vs/base/common/platform'; -import { isEqual } from 'vs/base/common/resources'; +import { isEqual, hasToIgnoreCase } from 'vs/base/common/resources'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; export class WorkspaceEditingService implements IWorkspaceEditingService { @@ -138,7 +138,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { private includesSingleFolderWorkspace(folders: URI[]): boolean { if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) { const workspaceFolder = this.contextService.getWorkspace().folders[0]; - return (folders.some(folder => isEqual(folder, workspaceFolder.uri, !isLinux))); + return (folders.some(folder => isEqual(folder, workspaceFolder.uri, hasToIgnoreCase(folder)))); } return false;