Skip to content

Commit f17030d

Browse files
author
Benjamin Pasero
committed
editors - adopt more extUri
1 parent 49fc0fe commit f17030d

13 files changed

Lines changed: 38 additions & 35 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 } from 'vs/base/common/resources';
8+
import { basename, extUri } 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';
@@ -357,7 +357,7 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources:
357357
for (const textEditorControl of textEditorControls) {
358358
if (isCodeEditor(textEditorControl)) {
359359
const model = textEditorControl.getModel();
360-
if (model?.uri?.toString() === file.resource.toString()) {
360+
if (extUri.isEqual(model?.uri, file.resource)) {
361361
return withNullAsUndefined(textEditorControl.saveViewState());
362362
}
363363
}

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 } from 'vs/base/common/resources';
7+
import { dirname, isEqual, basenameOrAuthority, extUri } 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 (model.uri.toString() === resource.toString()) {
310+
if (extUri.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/common/editor.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -782,16 +782,12 @@ export class SideBySideEditorInput extends EditorInput {
782782
}
783783

784784
matches(otherInput: unknown): boolean {
785-
if (super.matches(otherInput) === true) {
785+
if (otherInput === this) {
786786
return true;
787787
}
788788

789-
if (otherInput) {
790-
if (!(otherInput instanceof SideBySideEditorInput)) {
791-
return false;
792-
}
793-
794-
return this.secondary.matches(otherInput.secondary) && this.primary.matches(otherInput.primary);
789+
if (otherInput instanceof SideBySideEditorInput) {
790+
return this.primary.matches(otherInput.primary) && this.secondary.matches(otherInput.secondary);
795791
}
796792

797793
return false;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +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';
1819

1920
/**
2021
* A read-only text editor input whos contents are made of the provided resource that points to an existing
@@ -109,13 +110,12 @@ export class ResourceEditorInput extends AbstractTextResourceEditorInput impleme
109110
}
110111

111112
matches(otherInput: unknown): boolean {
112-
if (super.matches(otherInput) === true) {
113+
if (otherInput === this) {
113114
return true;
114115
}
115116

116-
// Compare by properties
117117
if (otherInput instanceof ResourceEditorInput) {
118-
return otherInput.resource.toString() === this.resource.toString();
118+
return extUri.isEqual(otherInput.resource, this.resource);
119119
}
120120

121121
return false;

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 } from 'vs/base/common/resources';
8+
import { basename, extUri } 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 && this.activeConflictResolutionResource.toString() === model.resource.toString()) {
118+
if (this.activeConflictResolutionResource && extUri.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/common/editors/fileEditorInput.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
314314
}
315315

316316
matches(otherInput: unknown): boolean {
317-
if (super.matches(otherInput) === true) {
317+
if (otherInput === this) {
318318
return true;
319319
}
320320

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

325325
return false;

src/vs/workbench/services/editor/browser/codeEditorService.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { TextEditorOptions } from 'vs/workbench/common/editor';
1212
import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
1313
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
1414
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
15+
import { extUri } from 'vs/base/common/resources';
1516

1617
export class CodeEditorService extends CodeEditorServiceImpl {
1718

@@ -47,13 +48,13 @@ export class CodeEditorService extends CodeEditorServiceImpl {
4748
// side as separate editor.
4849
const activeTextEditorControl = this.editorService.activeTextEditorControl;
4950
if (
50-
!sideBySide && // we need the current active group to be the taret
51-
isDiffEditor(activeTextEditorControl) && // we only support this for active text diff editors
52-
input.options && // we need options to apply
53-
input.resource && // we need a request resource to compare with
54-
activeTextEditorControl.getModel() && // we need a target model to compare with
55-
source === activeTextEditorControl.getModifiedEditor() && // we need the source of this request to be the modified side of the diff editor
56-
input.resource.toString() === activeTextEditorControl.getModel()!.modified.uri.toString() // we need the input resources to match with modified side
51+
!sideBySide && // we need the current active group to be the taret
52+
isDiffEditor(activeTextEditorControl) && // we only support this for active text diff editors
53+
input.options && // we need options to apply
54+
input.resource && // we need a request resource to compare with
55+
activeTextEditorControl.getModel() && // we need a target model to compare with
56+
source === activeTextEditorControl.getModifiedEditor() && // we need the source of this request to be the modified side of the diff editor
57+
extUri.isEqual(input.resource, activeTextEditorControl.getModel()!.modified.uri) // we need the input resources to match with modified side
5758
) {
5859
const targetEditor = activeTextEditorControl.getModifiedEditor();
5960

src/vs/workbench/services/editor/browser/editorService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
248248

249249
// Determine new resulting target resource
250250
let targetResource: URI;
251-
if (source.toString() === resource.toString()) {
251+
if (extUri.isEqual(source, resource)) {
252252
targetResource = target; // file got moved
253253
} else {
254254
const ignoreCase = !this.fileService.hasCapability(resource, FileSystemProviderCapabilities.PathCaseSensitive);

src/vs/workbench/services/history/browser/history.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { addDisposableListener, EventType, EventHelper } from 'vs/base/browser/d
3232
import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
3333
import { Schemas } from 'vs/base/common/network';
3434
import { onUnexpectedError } from 'vs/base/common/errors';
35+
import { extUri } from 'vs/base/common/resources';
3536

3637
/**
3738
* Stores the selection & view state of an editor and allows to compare it to other selection states.
@@ -577,7 +578,7 @@ export class HistoryService extends Disposable implements IHistoryService {
577578
const resourceEditorInputA = arg1 as IResourceEditorInput;
578579
const resourceEditorInputB = inputB as IResourceEditorInput;
579580

580-
return resourceEditorInputA && resourceEditorInputB && resourceEditorInputA.resource.toString() === resourceEditorInputB.resource.toString();
581+
return resourceEditorInputA && resourceEditorInputB && extUri.isEqual(resourceEditorInputA.resource, resourceEditorInputB.resource);
581582
}
582583

583584
private matchesFile(resource: URI, arg2: IEditorInput | IResourceEditorInput | FileChangesEvent): boolean {
@@ -595,12 +596,12 @@ export class HistoryService extends Disposable implements IHistoryService {
595596
return false; // make sure to only check this when workbench has restored (for https://github.com/Microsoft/vscode/issues/48275)
596597
}
597598

598-
return inputResource.toString() === resource.toString();
599+
return extUri.isEqual(inputResource, resource);
599600
}
600601

601602
const resourceEditorInput = arg2 as IResourceEditorInput;
602603

603-
return resourceEditorInput?.resource.toString() === resource.toString();
604+
return extUri.isEqual(resourceEditorInput?.resource, resource);
604605
}
605606

606607
//#endregion

src/vs/workbench/services/textfile/browser/textFileService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
1919
import { Schemas } from 'vs/base/common/network';
2020
import { createTextBufferFactoryFromSnapshot, createTextBufferFactoryFromStream } from 'vs/editor/common/model/textModel';
2121
import { IModelService } from 'vs/editor/common/services/modelService';
22-
import { joinPath, dirname, basename, toLocalResource } from 'vs/base/common/resources';
22+
import { joinPath, dirname, basename, toLocalResource, extUri } from 'vs/base/common/resources';
2323
import { IDialogService, IFileDialogService, IConfirmation } from 'vs/platform/dialogs/common/dialogs';
2424
import { VSBuffer } from 'vs/base/common/buffer';
2525
import { ITextSnapshot, ITextModel } from 'vs/editor/common/model';
@@ -224,7 +224,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
224224
}
225225

226226
// Just save if target is same as models own resource
227-
if (source.toString() === target.toString()) {
227+
if (extUri.isEqual(source, target)) {
228228
return this.save(source, { ...options, force: true /* force to save, even if not dirty (https://github.com/microsoft/vscode/issues/99619) */ });
229229
}
230230

0 commit comments

Comments
 (0)