Skip to content

Commit 44703f2

Browse files
committed
Replaces comparers with simple function
1 parent 868e764 commit 44703f2

File tree

9 files changed

+23
-51
lines changed

9 files changed

+23
-51
lines changed

src/commands/closeUnchangedFiles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type { Container } from '../container';
44
import { showGenericErrorMessage } from '../messages';
55
import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker';
66
import { command } from '../system/-webview/command';
7-
import { UriComparer } from '../system/comparers';
87
import { Logger } from '../system/logger';
8+
import { uriEquals } from '../system/uri';
99
import { GlCommandBase } from './commandBase';
1010

1111
export interface CloseUnchangedFilesCommandArgs {
@@ -46,12 +46,12 @@ export class CloseUnchangedFilesCommand extends GlCommandBase {
4646
tab.input instanceof TabInputNotebook
4747
) {
4848
const inputUri = tab.input.uri;
49-
if (hasNoChangedFiles || !args.uris.some(uri => UriComparer.equals(uri, inputUri))) {
49+
if (hasNoChangedFiles || !args.uris.some(uri => uriEquals(uri, inputUri))) {
5050
void window.tabGroups.close(tab, true);
5151
}
5252
} else if (tab.input instanceof TabInputTextDiff || tab.input instanceof TabInputNotebookDiff) {
5353
const inputUri = tab.input.modified;
54-
if (hasNoChangedFiles || !args.uris.some(uri => UriComparer.equals(uri, inputUri))) {
54+
if (hasNoChangedFiles || !args.uris.some(uri => uriEquals(uri, inputUri))) {
5555
void window.tabGroups.close(tab, true);
5656
}
5757
}

src/commands/openFileOnRemote.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { isSha } from '../git/utils/revision.utils';
1010
import { showGenericErrorMessage } from '../messages';
1111
import { showReferencePicker } from '../quickpicks/referencePicker';
1212
import { command, executeCommand } from '../system/-webview/command';
13-
import { UriComparer } from '../system/comparers';
1413
import { Logger } from '../system/logger';
1514
import { pad, splitSingle } from '../system/string';
15+
import { uriEquals } from '../system/uri';
1616
import { StatusFileNode } from '../views/nodes/statusFileNode';
1717
import { ActiveEditorCommand } from './commandBase';
1818
import { getCommandUri } from './commandBase.utils';
@@ -121,7 +121,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
121121

122122
let range: Range | undefined;
123123
if (args.range) {
124-
if (editor != null && UriComparer.equals(editor.document.uri, uri)) {
124+
if (editor != null && uriEquals(editor.document.uri, uri)) {
125125
range = new Range(
126126
editor.selection.start.with({ line: editor.selection.start.line + 1 }),
127127
editor.selection.end.with({

src/commands/openOnlyChangedFiles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker';
77
import { command } from '../system/-webview/command';
88
import { findOrOpenEditors } from '../system/-webview/vscode';
99
import { filterMap } from '../system/array';
10-
import { UriComparer } from '../system/comparers';
1110
import { Logger } from '../system/logger';
11+
import { uriEquals } from '../system/uri';
1212
import { GlCommandBase } from './commandBase';
1313

1414
export interface OpenOnlyChangedFilesCommandArgs {
@@ -65,7 +65,7 @@ export class OpenOnlyChangedFilesCommand extends GlCommandBase {
6565

6666
if (inputUri == null) continue;
6767
// eslint-disable-next-line no-loop-func
68-
matchingUri = args.uris.find(uri => UriComparer.equals(uri, inputUri));
68+
matchingUri = args.uris.find(uri => uriEquals(uri, inputUri));
6969
if (matchingUri != null) {
7070
openUris.delete(matchingUri);
7171
} else {

src/git/gitUri.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import type { GitHubAuthorityMetadata } from '../plus/remotehub';
66
import { formatPath } from '../system/-webview/formatPath';
77
import { getBestPath, relativeDir, splitPath } from '../system/-webview/path';
88
import { isVirtualUri } from '../system/-webview/vscode';
9-
import { UriComparer } from '../system/comparers';
109
import { memoize } from '../system/decorators/-webview/memoize';
1110
import { debug } from '../system/decorators/log';
1211
import { basename, normalizePath } from '../system/path';
12+
import { uriEquals } from '../system/uri';
1313
import type { RevisionUriData } from './gitProvider';
1414
import { decodeGitLensRevisionUriAuthority, decodeRemoteHubAuthority } from './gitUri.authority';
1515
import type { GitFile } from './models/file';
@@ -213,7 +213,7 @@ export class GitUri extends (Uri as any as UriEx) {
213213
}
214214

215215
equals(uri: Uri | undefined): boolean {
216-
if (!UriComparer.equals(this, uri)) return false;
216+
if (!uriEquals(this, uri)) return false;
217217

218218
return this.sha === (isGitUri(uri) ? uri.sha : undefined);
219219
}

src/hovers/lineHoverController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import type { CancellationToken, ConfigurationChangeEvent, Position, TextDocumen
22
import { Disposable, Hover, languages, Range, window } from 'vscode';
33
import type { Container } from '../container';
44
import { configuration } from '../system/-webview/configuration';
5-
import { UriComparer } from '../system/comparers';
65
import { debug } from '../system/decorators/log';
76
import { once } from '../system/event';
87
import { Logger } from '../system/logger';
8+
import { uriEquals } from '../system/uri';
99
import type { LinesChangeEvent } from '../trackers/lineTracker';
1010
import { changesMessage, detailsMessage } from './hovers';
1111

@@ -191,7 +191,7 @@ export class LineHoverController implements Disposable {
191191
}
192192

193193
private isRegistered(uri: Uri | undefined) {
194-
return this._hoverProviderDisposable != null && UriComparer.equals(this._uri, uri);
194+
return this._hoverProviderDisposable != null && uriEquals(this._uri, uri);
195195
}
196196

197197
private register(editor: TextEditor | undefined) {

src/system/comparers.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/system/uri.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { Uri } from 'vscode';
2+
3+
export function uriEquals(lhs: Uri | undefined, rhs: Uri | undefined): boolean {
4+
if (lhs === rhs) return true;
5+
if (lhs == null || rhs == null) return false;
6+
7+
return lhs.toString() === rhs.toString();
8+
}

src/views/nodes/fileHistoryTrackerNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import { showReferencePicker } from '../../quickpicks/referencePicker';
88
import { setContext } from '../../system/-webview/context';
99
import { isFolderUri } from '../../system/-webview/path';
1010
import { isVirtualUri } from '../../system/-webview/vscode';
11-
import { UriComparer } from '../../system/comparers';
1211
import { gate } from '../../system/decorators/-webview/gate';
1312
import { debug, log } from '../../system/decorators/log';
1413
import { weakEvent } from '../../system/event';
1514
import type { Deferrable } from '../../system/function';
1615
import { debounce } from '../../system/function';
1716
import { Logger } from '../../system/logger';
1817
import { getLogScope, setLogScopeExit } from '../../system/logger.scope';
18+
import { uriEquals } from '../../system/uri';
1919
import type { FileHistoryView } from '../fileHistoryView';
2020
import { SubscribeableViewNode } from './abstract/subscribeableViewNode';
2121
import type { ViewNode } from './abstract/viewNode';
@@ -170,7 +170,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode<'file-history-
170170
}
171171
}
172172

173-
if (this.hasUri && UriComparer.equals(uri ?? gitUri, this.uri)) {
173+
if (this.hasUri && uriEquals(uri ?? gitUri, this.uri)) {
174174
return true;
175175
}
176176

src/views/nodes/lineHistoryTrackerNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import { isBranchReference } from '../../git/utils/reference.utils';
77
import { isSha } from '../../git/utils/revision.utils';
88
import { showReferencePicker } from '../../quickpicks/referencePicker';
99
import { setContext } from '../../system/-webview/context';
10-
import { UriComparer } from '../../system/comparers';
1110
import { gate } from '../../system/decorators/-webview/gate';
1211
import { debug, log } from '../../system/decorators/log';
1312
import { weakEvent } from '../../system/event';
1413
import { debounce } from '../../system/function';
1514
import { Logger } from '../../system/logger';
1615
import { getLogScope, setLogScopeExit } from '../../system/logger.scope';
16+
import { uriEquals } from '../../system/uri';
1717
import type { LinesChangeEvent } from '../../trackers/lineTracker';
1818
import type { FileHistoryView } from '../fileHistoryView';
1919
import type { LineHistoryView } from '../lineHistoryView';
@@ -186,7 +186,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode<
186186

187187
if (
188188
this.hasUri &&
189-
UriComparer.equals(gitUri, this.uri) &&
189+
uriEquals(gitUri, this.uri) &&
190190
this._selection != null &&
191191
editor.selection.isEqual(this._selection)
192192
) {

0 commit comments

Comments
 (0)