From 67cf0074328dee00fb3813130d0ebf834b3d9160 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 12 Apr 2017 07:33:27 +0200 Subject: [PATCH] File from UNC-folders twice time opened in same instance after changes (fixes #24003) --- src/vs/base/common/map.ts | 10 +--------- src/vs/code/electron-main/window.ts | 1 - src/vs/workbench/browser/labels.ts | 2 +- .../parts/files/browser/editors/textFileEditor.ts | 4 ++-- .../files/browser/fileActions.contribution.ts | 3 +-- .../workbench/parts/files/browser/fileActions.ts | 6 +++--- .../parts/files/browser/views/explorerView.ts | 14 +++++++------- .../parts/files/browser/views/explorerViewer.ts | 8 ++++---- .../parts/files/common/editors/fileEditorInput.ts | 8 ++++---- .../parts/files/common/explorerViewModel.ts | 4 ++-- .../parts/markers/browser/markersPanel.ts | 3 +-- .../parts/search/browser/searchViewlet.ts | 4 ++-- .../search/test/browser/searchActions.test.ts | 1 + .../workbench/services/files/node/fileService.ts | 2 +- .../workbench/services/history/browser/history.ts | 6 +++--- 15 files changed, 33 insertions(+), 43 deletions(-) diff --git a/src/vs/base/common/map.ts b/src/vs/base/common/map.ts index 7563aa5b98d..09c03b971b0 100644 --- a/src/vs/base/common/map.ts +++ b/src/vs/base/common/map.ts @@ -6,7 +6,6 @@ 'use strict'; import URI from 'vs/base/common/uri'; -import { Schemas } from 'vs/base/common/network'; export interface Key { toString(): string; @@ -450,14 +449,7 @@ export class ResourceMap { } private toKey(resource: URI): string { - let key: string; - - if (resource.scheme === Schemas.file) { - key = resource.fsPath; - } else { - key = resource.toString(); - } - + let key = resource.toString(); if (this.ignoreCase) { key = key.toLowerCase(); } diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index 4f63834ebe7..073ab8d7d9f 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -572,7 +572,6 @@ export class VSCodeWindow { } let background = this.storageService.getItem(VSCodeWindow.themeBackgroundStorageKey, null); - console.log('itm ' + background); if (!background) { let baseTheme = this.getBaseTheme(); return baseTheme === 'hc-black' ? '#000000' : (baseTheme === 'vs' ? '#FFFFFF' : (platform.isMacintosh ? '#171717' : '#1E1E1E')); // https://github.com/electron/electron/issues/5150 diff --git a/src/vs/workbench/browser/labels.ts b/src/vs/workbench/browser/labels.ts index c6f8cc22422..e7cb33774ac 100644 --- a/src/vs/workbench/browser/labels.ts +++ b/src/vs/workbench/browser/labels.ts @@ -73,7 +73,7 @@ export class ResourceLabel extends IconLabel { const oldResource = this.label ? this.label.resource : void 0; if (newResource && oldResource) { - return newResource.fsPath !== oldResource.fsPath; + return newResource.toString() !== oldResource.toString(); } if (!newResource && !oldResource) { diff --git a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts index 5960046face..5ff0267140d 100644 --- a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts +++ b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts @@ -19,7 +19,7 @@ import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel' import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput'; import { ExplorerViewlet } from 'vs/workbench/parts/files/browser/explorerViewlet'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; -import { IFileOperationResult, FileOperationResult, FileChangesEvent, IFileService, isEqual } from 'vs/platform/files/common/files'; +import { IFileOperationResult, FileOperationResult, FileChangesEvent, IFileService } from 'vs/platform/files/common/files'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IStorageService } from 'vs/platform/storage/common/storage'; @@ -123,7 +123,7 @@ export class TextFileEditor extends BaseTextEditor { const hasInput = !!this.input; const modelDisposed = textFileModel.isDisposed(); - const inputChanged = hasInput && !isEqual(this.input.getResource().fsPath, textFileModel.getResource().fsPath); + const inputChanged = hasInput && this.input.getResource().toString() !== textFileModel.getResource().toString(); if ( !hasInput || // editor got hidden meanwhile modelDisposed || // input got disposed meanwhile diff --git a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts index ef60615a029..7c3bd0125d2 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts @@ -25,7 +25,6 @@ import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/c import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { explorerItemToFileResource, ExplorerFocusCondition, FilesExplorerFocusCondition } from 'vs/workbench/parts/files/common/files'; -import { isEqual } from 'vs/platform/files/common/files'; class FilesViewerActionContributor extends ActionBarContributor { @@ -88,7 +87,7 @@ class FilesViewerActionContributor extends ActionBarContributor { } const workspace = this.contextService.getWorkspace(); - const isRoot = workspace && isEqual(stat.resource.fsPath, workspace.resource.fsPath); + const isRoot = workspace && stat.resource.toString() === workspace.resource.toString(); // Copy File/Folder if (!isRoot) { diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index 815d2be4570..e8beea1288f 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -963,7 +963,7 @@ export class PasteFileAction extends BaseFileAction { // Find target let target: FileStat; - if (isEqual(this.element.resource.fsPath, fileToCopy.resource.fsPath)) { + if (this.element.resource.toString() === fileToCopy.resource.toString()) { target = this.element.parent; } else { target = this.element.isDirectory ? this.element : this.element.parent; @@ -1270,7 +1270,7 @@ export class CompareResourcesAction extends Action { } // Check if target is identical to source - if (isEqual(this.resource.fsPath, globalResourceToCompare.fsPath)) { + if (this.resource.toString() === globalResourceToCompare.toString()) { return false; } @@ -1365,7 +1365,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting { const editor = getCodeEditor(activeEditor); if (editor) { const activeResource = toResource(activeEditor.input, { supportSideBySide: true, filter: ['file', 'untitled'] }); - if (activeResource && isEqual(activeResource.fsPath, source.fsPath)) { + if (activeResource && activeResource.toString() === source.toString()) { viewStateOfSource = editor.saveViewState(); } } diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index 277acb543ab..684c966b261 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -17,7 +17,7 @@ import { prepareActions } from 'vs/workbench/browser/actionBarRegistry'; import { ITree } from 'vs/base/parts/tree/browser/tree'; import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { IFilesConfiguration, ExplorerFolderContext, FilesExplorerFocussedContext, ExplorerFocussedContext } from 'vs/workbench/parts/files/common/files'; -import { FileOperation, FileOperationEvent, IResolveFileOptions, FileChangeType, FileChangesEvent, IFileChange, IFileService, isEqual, isEqualOrParent } from 'vs/platform/files/common/files'; +import { FileOperation, FileOperationEvent, IResolveFileOptions, FileChangeType, FileChangesEvent, IFileChange, IFileService, isEqualOrParent } from 'vs/platform/files/common/files'; import { RefreshViewExplorerAction, NewFolderAction, NewFileAction } from 'vs/workbench/parts/files/browser/fileActions'; import { FileDragAndDrop, FileFilter, FileSorter, FileController, FileRenderer, FileDataSource, FileViewletState, FileAccessibilityProvider } from 'vs/workbench/parts/files/browser/views/explorerViewer'; import { toResource } from 'vs/workbench/common/editor'; @@ -440,12 +440,12 @@ export class ExplorerView extends CollapsibleViewletView { // Only update focus if renamed/moved element is selected let restoreFocus = false; const focus: FileStat = this.explorerViewer.getFocus(); - if (focus && focus.resource && isEqual(focus.resource.fsPath, oldResource.fsPath)) { + if (focus && focus.resource && focus.resource.toString() === oldResource.toString()) { restoreFocus = true; } // Handle Rename - if (oldParentResource && newParentResource && isEqual(oldParentResource.fsPath, newParentResource.fsPath)) { + if (oldParentResource && newParentResource && oldParentResource.toString() === newParentResource.toString()) { modelElement = this.root.find(oldResource); if (modelElement) { @@ -729,7 +729,7 @@ export class ExplorerView extends CollapsibleViewletView { */ private getResolvedDirectories(stat: FileStat, resolvedDirectories: URI[]): void { if (stat.isDirectoryResolved) { - if (!isEqual(stat.resource.fsPath, this.contextService.getWorkspace().resource.fsPath)) { + if (stat.resource.toString() !== this.contextService.getWorkspace().resource.toString()) { // Drop those path which are parents of the current one for (let i = resolvedDirectories.length - 1; i >= 0; i--) { @@ -758,7 +758,7 @@ export class ExplorerView extends CollapsibleViewletView { public select(resource: URI, reveal: boolean = this.autoReveal): TPromise { // Require valid path - if (!resource || isEqual(resource.fsPath, this.contextService.getWorkspace().resource.fsPath)) { + if (!resource || resource.toString() === this.contextService.getWorkspace().resource.toString()) { return TPromise.as(null); } @@ -798,7 +798,7 @@ export class ExplorerView extends CollapsibleViewletView { const currentSelection: FileStat[] = this.explorerViewer.getSelection(); for (let i = 0; i < currentSelection.length; i++) { - if (isEqual(currentSelection[i].resource.fsPath, resource.fsPath)) { + if (currentSelection[i].resource.toString() === resource.toString()) { return currentSelection[i]; } } @@ -842,7 +842,7 @@ export class ExplorerView extends CollapsibleViewletView { // Keep list of expanded folders to restore on next load if (this.root) { const expanded = this.explorerViewer.getExpandedElements() - .filter((e: FileStat) => !isEqual(e.resource.fsPath, this.contextService.getWorkspace().resource.fsPath)) + .filter((e: FileStat) => e.resource.toString() !== this.contextService.getWorkspace().resource.toString()) .map((e: FileStat) => e.resource.toString()); this.settings[ExplorerView.MEMENTO_EXPANDED_FOLDER_RESOURCES] = expanded; diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index 3d24249410c..4494835dff8 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -112,7 +112,7 @@ export class FileDataSource implements IDataSource { // Return if root reached const workspace = this.contextService.getWorkspace(); - if (workspace && isEqual(stat.resource.fsPath, workspace.resource.fsPath)) { + if (workspace && stat.resource.toString() === workspace.resource.toString()) { return TPromise.as(null); } @@ -424,7 +424,7 @@ export class FileController extends DefaultController { // Handle root const workspace = this.contextService.getWorkspace(); - if (workspace && isEqual(stat.resource.fsPath, workspace.resource.fsPath)) { + if (workspace && stat.resource.toString() === workspace.resource.toString()) { tree.clearFocus(payload); tree.clearSelection(payload); @@ -699,7 +699,7 @@ export class FileDragAndDrop implements IDragAndDrop { return true; // NewStatPlaceholders can not be moved } - if (isEqual(source.resource.fsPath, target.resource.fsPath)) { + if (source.resource.toString() === target.resource.toString()) { return true; // Can not move anything onto itself } @@ -723,7 +723,7 @@ export class FileDragAndDrop implements IDragAndDrop { } const workspace = this.contextService.getWorkspace(); - if (workspace && !isEqual(target.resource.fsPath, workspace.resource.fsPath)) { + if (workspace && target.resource.toString() !== workspace.resource.toString()) { return fromDesktop || isCopy ? DRAG_OVER_ACCEPT_BUBBLE_UP_COPY : DRAG_OVER_ACCEPT_BUBBLE_UP; } diff --git a/src/vs/workbench/parts/files/common/editors/fileEditorInput.ts b/src/vs/workbench/parts/files/common/editors/fileEditorInput.ts index 7c0df2e2875..8fee6c2d8b2 100644 --- a/src/vs/workbench/parts/files/common/editors/fileEditorInput.ts +++ b/src/vs/workbench/parts/files/common/editors/fileEditorInput.ts @@ -12,7 +12,7 @@ import URI from 'vs/base/common/uri'; import { EncodingMode, ConfirmResult, EditorInput, IFileEditorInput } from 'vs/workbench/common/editor'; import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel'; import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel'; -import { IFileOperationResult, FileOperationResult, isEqual } from 'vs/platform/files/common/files'; +import { IFileOperationResult, FileOperationResult } from 'vs/platform/files/common/files'; import { BINARY_FILE_EDITOR_ID, TEXT_FILE_EDITOR_ID, FILE_EDITOR_INPUT_ID } from 'vs/workbench/parts/files/common/files'; import { ITextFileService, AutoSaveMode, ModelState, TextFileModelChangeEvent } from 'vs/workbench/services/textfile/common/textfiles'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; @@ -75,13 +75,13 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput { } private onDirtyStateChange(e: TextFileModelChangeEvent): void { - if (isEqual(e.resource.fsPath, this.resource.fsPath)) { + if (e.resource.toString() === this.resource.toString()) { this._onDidChangeDirty.fire(); } } private onModelOrphanedChanged(e: TextFileModelChangeEvent): void { - if (isEqual(e.resource.fsPath, this.resource.fsPath)) { + if (e.resource.toString() === this.resource.toString()) { this._onDidChangeLabel.fire(); } } @@ -265,7 +265,7 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput { } if (otherInput) { - return otherInput instanceof FileEditorInput && isEqual(otherInput.resource.fsPath, this.resource.fsPath); + return otherInput instanceof FileEditorInput && otherInput.resource.toString() === this.resource.toString(); } return false; diff --git a/src/vs/workbench/parts/files/common/explorerViewModel.ts b/src/vs/workbench/parts/files/common/explorerViewModel.ts index df308c44db1..64b3abbe18f 100644 --- a/src/vs/workbench/parts/files/common/explorerViewModel.ts +++ b/src/vs/workbench/parts/files/common/explorerViewModel.ts @@ -85,7 +85,7 @@ export class FileStat implements IFileStat { * exists locally. */ public static mergeLocalWithDisk(disk: FileStat, local: FileStat): void { - if (!isEqual(disk.resource.fsPath, local.resource.fsPath)) { + if (disk.resource.toString() !== local.resource.toString()) { return; // Merging only supported for stats with the same resource } @@ -180,7 +180,7 @@ export class FileStat implements IFileStat { */ public removeChild(child: FileStat): void { for (let i = 0; i < this.children.length; i++) { - if (isEqual(this.children[i].resource.fsPath, child.resource.fsPath)) { + if (this.children[i].resource.toString() === child.resource.toString()) { this.children.splice(i, 1); break; } diff --git a/src/vs/workbench/parts/markers/browser/markersPanel.ts b/src/vs/workbench/parts/markers/browser/markersPanel.ts index ba408f9a445..deafb8d19be 100644 --- a/src/vs/workbench/parts/markers/browser/markersPanel.ts +++ b/src/vs/workbench/parts/markers/browser/markersPanel.ts @@ -36,7 +36,6 @@ import { ContributableActionProvider } from 'vs/workbench/browser/actionBarRegis import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IListService } from 'vs/platform/list/browser/listService'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { isEqual } from 'vs/platform/files/common/files'; export class MarkersPanel extends Panel { @@ -345,7 +344,7 @@ export class MarkersPanel extends Panel { let selectedElement = this.tree.getSelection(); if (selectedElement && selectedElement.length > 0) { if (selectedElement[0] instanceof Marker) { - if (isEqual(resource.uri, selectedElement[0].marker.resource)) { + if (resource.uri.toString() === selectedElement[0].marker.resource.toString()) { return true; } } diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index 12122f10a2a..daf2ae88b55 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -30,7 +30,7 @@ import { Scope } from 'vs/workbench/common/memento'; import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { getOutOfWorkspaceEditorResources } from 'vs/workbench/common/editor'; -import { FileChangeType, FileChangesEvent, IFileService, isEqual } from 'vs/platform/files/common/files'; +import { FileChangeType, FileChangesEvent, IFileService } from 'vs/platform/files/common/files'; import { Viewlet } from 'vs/workbench/browser/viewlet'; import { Match, FileMatch, SearchModel, FileMatchOrMatch, IChangeEvent, ISearchWorkbenchService } from 'vs/workbench/parts/search/common/searchModel'; import { QueryBuilder } from 'vs/workbench/parts/search/common/searchQuery'; @@ -914,7 +914,7 @@ export class SearchViewlet extends Viewlet { return; } - if (isEqual(workspace.resource.fsPath, resource.fsPath)) { + if (workspace.resource.toString() === resource.toString()) { this.inputPatternIncludes.setValue(''); this.searchWidget.focus(); return; diff --git a/src/vs/workbench/parts/search/test/browser/searchActions.test.ts b/src/vs/workbench/parts/search/test/browser/searchActions.test.ts index e9bd0455676..705560719d8 100644 --- a/src/vs/workbench/parts/search/test/browser/searchActions.test.ts +++ b/src/vs/workbench/parts/search/test/browser/searchActions.test.ts @@ -31,6 +31,7 @@ suite('Search Actions', () => { instantiationService.stub(IModelService, stubModelService(instantiationService)); instantiationService.stub(IKeybindingService, {}); instantiationService.stub(IKeybindingService, 'resolveKeybinding', (keybinding: Keybinding) => [new USLayoutResolvedKeybinding(keybinding, OS)]); + instantiationService.stub(IKeybindingService, 'lookupKeybinding', (id: string) => null); counter = 0; }); diff --git a/src/vs/workbench/services/files/node/fileService.ts b/src/vs/workbench/services/files/node/fileService.ts index 33bca744087..435e0dea1d7 100644 --- a/src/vs/workbench/services/files/node/fileService.ts +++ b/src/vs/workbench/services/files/node/fileService.ts @@ -601,7 +601,7 @@ export class FileService implements IFileService { // check if the resource is a child of the resource with override and use // the provided encoding in that case - if (isParent(resource.fsPath, override.resource.fsPath)) { + if (isParent(resource.fsPath, override.resource.fsPath, !isLinux /* ignorecase */)) { return override.encoding; } } diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index a3a7bead6a0..47074728c5d 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -14,7 +14,7 @@ import { IEditor as IBaseEditor, IEditorInput, ITextEditorOptions, IResourceInpu import { EditorInput, IGroupEvent, IEditorRegistry, Extensions, toResource, IEditorGroup } from 'vs/workbench/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; -import { FileChangesEvent, IFileService, FileChangeType, isEqual } from 'vs/platform/files/common/files'; +import { FileChangesEvent, IFileService, FileChangeType } from 'vs/platform/files/common/files'; import { Selection } from 'vs/editor/common/core/selection'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; @@ -590,12 +590,12 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic if (arg2 instanceof EditorInput) { const file = toResource(arg2, { filter: 'file' }); - return file && isEqual(file.fsPath, resource.fsPath); + return file && file.toString() === resource.toString(); } const resourceInput = arg2 as IResourceInput; - return resourceInput && isEqual(resourceInput.resource.fsPath, resource.fsPath); + return resourceInput && resourceInput.resource.toString() === resource.toString(); } public getHistory(): (IEditorInput | IResourceInput)[] {