Skip to content

Commit c314be2

Browse files
author
Benjamin Pasero
committed
some 💄 around URI identity method usages
1 parent 467b3c6 commit c314be2

18 files changed

Lines changed: 48 additions & 47 deletions

File tree

src/vs/workbench/browser/dnd.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { hasWorkspaceFileExtension, IWorkspaceFolderCreationData, IRecentFile, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
77
import { normalize } from 'vs/base/common/path';
8-
import { basename, extUri } from 'vs/base/common/resources';
8+
import { basename, isEqual } from 'vs/base/common/resources';
99
import { IFileService } from 'vs/platform/files/common/files';
1010
import { IWindowOpenable } from 'vs/platform/windows/common/windows';
1111
import { URI } from 'vs/base/common/uri';
@@ -352,7 +352,7 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources:
352352
for (const textEditorControl of textEditorControls) {
353353
if (isCodeEditor(textEditorControl)) {
354354
const model = textEditorControl.getModel();
355-
if (extUri.isEqual(model?.uri, file.resource)) {
355+
if (isEqual(model?.uri, file.resource)) {
356356
return withNullAsUndefined(textEditorControl.saveViewState());
357357
}
358358
}

src/vs/workbench/browser/labels.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { URI } from 'vs/base/common/uri';
7-
import { dirname, isEqual, basenameOrAuthority, extUri } from 'vs/base/common/resources';
7+
import { dirname, isEqual, basenameOrAuthority } from 'vs/base/common/resources';
88
import { IconLabel, IIconLabelValueOptions, IIconLabelCreationOptions } from 'vs/base/browser/ui/iconLabel/iconLabel';
99
import { IModeService } from 'vs/editor/common/services/modeService';
1010
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
@@ -307,7 +307,7 @@ class ResourceLabelWidget extends IconLabel {
307307
return; // only update if resource exists
308308
}
309309

310-
if (extUri.isEqual(model.uri, resource)) {
310+
if (isEqual(model.uri, resource)) {
311311
if (this.lastKnownDetectedModeId !== model.getModeId()) {
312312
this.render(true); // update if the language id of the model has changed from our last known state
313313
}

src/vs/workbench/browser/parts/editor/rangeDecorations.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CursorChangeReason, ICursorPositionChangedEvent } from 'vs/editor/commo
1212
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
1313
import { ICodeEditor, isCodeEditor, isCompositeEditor } from 'vs/editor/browser/editorBrowser';
1414
import { TrackedRangeStickiness, IModelDecorationsChangeAccessor } from 'vs/editor/common/model';
15+
import { isEqual } from 'vs/base/common/resources';
1516

1617
export interface IRangeHighlightDecoration {
1718
resource: URI;
@@ -65,10 +66,8 @@ export class RangeHighlightDecorations extends Disposable {
6566
private getEditor(resourceRange: IRangeHighlightDecoration): ICodeEditor | undefined {
6667
const activeEditor = this.editorService.activeEditor;
6768
const resource = activeEditor && activeEditor.resource;
68-
if (resource) {
69-
if (resource.toString() === resourceRange.resource.toString()) {
70-
return this.editorService.activeTextEditorControl as ICodeEditor;
71-
}
69+
if (resource && isEqual(resource, resourceRange.resource)) {
70+
return this.editorService.activeTextEditorControl as ICodeEditor;
7271
}
7372

7473
return undefined;

src/vs/workbench/browser/parts/editor/textDiffEditor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/commo
3030
import { CancellationToken } from 'vs/base/common/cancellation';
3131
import { EditorActivation, IEditorOptions } from 'vs/platform/editor/common/editor';
3232
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
33+
import { isEqual } from 'vs/base/common/resources';
3334

3435
/**
3536
* The text editor that leverages the diff text editor for the editing experience.
@@ -332,7 +333,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditorPan
332333
return null; // model URI is needed to make sure we save the view state correctly
333334
}
334335

335-
if (modelUri.toString() !== resource.toString()) {
336+
if (!isEqual(modelUri, resource)) {
336337
return null; // prevent saving view state for a model that is not the expected one
337338
}
338339

src/vs/workbench/common/editor/resourceEditorInput.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IFileService } from 'vs/platform/files/common/files';
1515
import { ILabelService } from 'vs/platform/label/common/label';
1616
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
1717
import { AbstractTextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput';
18-
import { extUri } from 'vs/base/common/resources';
18+
import { isEqual } from 'vs/base/common/resources';
1919

2020
/**
2121
* A read-only text editor input whos contents are made of the provided resource that points to an existing
@@ -115,7 +115,7 @@ export class ResourceEditorInput extends AbstractTextResourceEditorInput impleme
115115
}
116116

117117
if (otherInput instanceof ResourceEditorInput) {
118-
return extUri.isEqual(otherInput.resource, this.resource);
118+
return isEqual(otherInput.resource, this.resource);
119119
}
120120

121121
return false;

src/vs/workbench/common/editor/textResourceEditorInput.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { IFileService, FileSystemProviderCapabilities } from 'vs/platform/files/
1212
import { ILabelService } from 'vs/platform/label/common/label';
1313
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
1414
import { Schemas } from 'vs/base/common/network';
15-
import { dirname, extUri } from 'vs/base/common/resources';
15+
import { dirname, isEqual } from 'vs/base/common/resources';
1616

1717
/**
1818
* The base class for all editor inputs that open in text editors.
@@ -69,7 +69,7 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput implem
6969
}
7070

7171
setPreferredResource(preferredResource: URI): void {
72-
if (!extUri.isEqual(preferredResource, this._preferredResource)) {
72+
if (!isEqual(preferredResource, this._preferredResource)) {
7373
this._preferredResource = preferredResource;
7474

7575
this.updateLabel();
@@ -219,7 +219,7 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput implem
219219
}
220220

221221
// If the target is a different resource, return with a new editor input
222-
if (!extUri.isEqual(target, this.resource)) {
222+
if (!isEqual(target, this.resource)) {
223223
return this.editorService.createEditorInput({ resource: target });
224224
}
225225

src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as nls from 'vs/nls';
77
import { toErrorMessage } from 'vs/base/common/errorMessage';
8-
import { basename, extUri } from 'vs/base/common/resources';
8+
import { basename, isEqual } from 'vs/base/common/resources';
99
import { Action, IAction } from 'vs/base/common/actions';
1010
import { URI } from 'vs/base/common/uri';
1111
import { FileOperationError, FileOperationResult } from 'vs/platform/files/common/files';
@@ -115,7 +115,7 @@ export class TextFileSaveErrorHandler extends Disposable implements ISaveErrorHa
115115
if (fileOperationError.fileOperationResult === FileOperationResult.FILE_MODIFIED_SINCE) {
116116

117117
// If the user tried to save from the opened conflict editor, show its message again
118-
if (this.activeConflictResolutionResource && extUri.isEqual(this.activeConflictResolutionResource, model.resource)) {
118+
if (this.activeConflictResolutionResource && isEqual(this.activeConflictResolutionResource, model.resource)) {
119119
if (this.storageService.getBoolean(LEARN_MORE_DIRTY_WRITE_IGNORE_KEY, StorageScope.GLOBAL)) {
120120
return; // return if this message is ignored
121121
}

src/vs/workbench/contrib/files/browser/files.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { Schemas } from 'vs/base/common/network';
3939
import { WorkspaceWatcher } from 'vs/workbench/contrib/files/common/workspaceWatcher';
4040
import { editorConfigurationBaseNode } from 'vs/editor/common/config/commonEditorConfig';
4141
import { DirtyFilesIndicator } from 'vs/workbench/contrib/files/common/dirtyFilesIndicator';
42-
import { extUri } from 'vs/base/common/resources';
42+
import { isEqual } from 'vs/base/common/resources';
4343

4444
// Viewlet Action
4545
export class OpenExplorerViewletAction extends ShowViewletAction {
@@ -131,7 +131,7 @@ class FileEditorInputFactory implements IEditorInputFactory {
131131
const preferredResource = fileEditorInput.preferredResource;
132132
const serializedFileEditorInput: ISerializedFileEditorInput = {
133133
resourceJSON: resource.toJSON(),
134-
preferredResourceJSON: extUri.isEqual(resource, preferredResource) ? undefined : preferredResource, // only storing preferredResource if it differs from the resource
134+
preferredResourceJSON: isEqual(resource, preferredResource) ? undefined : preferredResource, // only storing preferredResource if it differs from the resource
135135
encoding: fileEditorInput.getEncoding(),
136136
modeId: fileEditorInput.getPreferredMode() // only using the preferred user associated mode here if available to not store redundant data
137137
};

src/vs/workbench/contrib/files/browser/views/explorerViewer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
2020
import { IThemeService } from 'vs/platform/theme/common/themeService';
2121
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
2222
import { IFilesConfiguration, IExplorerService, VIEW_ID } from 'vs/workbench/contrib/files/common/files';
23-
import { dirname, joinPath, isEqualOrParent, basename, distinctParents } from 'vs/base/common/resources';
23+
import { dirname, joinPath, basename, distinctParents } from 'vs/base/common/resources';
2424
import { InputBox, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
2525
import { localize } from 'vs/nls';
2626
import { attachInputBoxStyler } from 'vs/platform/theme/common/styler';
@@ -807,7 +807,8 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
807807
@IWorkingCopyFileService private workingCopyFileService: IWorkingCopyFileService,
808808
@IHostService private hostService: IHostService,
809809
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService,
810-
@IProgressService private readonly progressService: IProgressService
810+
@IProgressService private readonly progressService: IProgressService,
811+
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
811812
) {
812813
this.toDispose = [];
813814

@@ -911,7 +912,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
911912
return true; // Can not move a file to the same parent unless we copy
912913
}
913914

914-
if (isEqualOrParent(target.resource, source.resource)) {
915+
if (this.uriIdentityService.extUri.isEqualOrParent(target.resource, source.resource)) {
915916
return true; // Can not move a parent folder into one of its children
916917
}
917918

src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
1818
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
1919
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
2020
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
21-
import { extUri } from 'vs/base/common/resources';
21+
import { isEqual } from 'vs/base/common/resources';
2222
import { Event } from 'vs/base/common/event';
2323
import { IEditorViewState } from 'vs/editor/common/editorCommon';
2424

@@ -86,7 +86,7 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
8686

8787
// Once the text file model is created, we keep it inside
8888
// the input to be able to implement some methods properly
89-
if (extUri.isEqual(model.resource, this.resource)) {
89+
if (isEqual(model.resource, this.resource)) {
9090
this.model = model;
9191

9292
this.registerModelListeners(model);
@@ -303,7 +303,7 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
303303

304304
private getViewStateFor(group: GroupIdentifier): IEditorViewState | undefined {
305305
for (const editorPane of this.editorService.visibleEditorPanes) {
306-
if (editorPane.group.id === group && extUri.isEqual(editorPane.input.resource, this.resource)) {
306+
if (editorPane.group.id === group && isEqual(editorPane.input.resource, this.resource)) {
307307
if (isTextEditorPane(editorPane)) {
308308
return editorPane.getViewState();
309309
}
@@ -319,7 +319,7 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
319319
}
320320

321321
if (otherInput instanceof FileEditorInput) {
322-
return extUri.isEqual(otherInput.resource, this.resource);
322+
return isEqual(otherInput.resource, this.resource);
323323
}
324324

325325
return false;

0 commit comments

Comments
 (0)