Skip to content

Commit d65758c

Browse files
committed
use toString (via getComparisionKey) for compare and equal
1 parent 88e4a42 commit d65758c

1 file changed

Lines changed: 12 additions & 35 deletions

File tree

src/vs/base/common/resources.ts

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as extpath from 'vs/base/common/extpath';
77
import * as paths from 'vs/base/common/path';
88
import { URI, uriToFsPath } from 'vs/base/common/uri';
9-
import { equalsIgnoreCase, compare as strCompare, compareIgnoreCase } from 'vs/base/common/strings';
9+
import { equalsIgnoreCase, compare as strCompare } from 'vs/base/common/strings';
1010
import { Schemas } from 'vs/base/common/network';
1111
import { isLinux, isWindows } from 'vs/base/common/platform';
1212
import { CharCode } from 'vs/base/common/charCode';
@@ -138,32 +138,10 @@ export class ExtUri implements IExtUri {
138138
constructor(private _ignorePathCasing: (uri: URI) => boolean) { }
139139

140140
compare(uri1: URI, uri2: URI, ignoreFragment: boolean = false): number {
141-
// scheme
142-
let ret = strCompare(uri1.scheme, uri2.scheme);
143-
if (ret === 0) {
144-
// authority
145-
ret = compareIgnoreCase(uri1.authority, uri2.authority);
146-
if (ret === 0) {
147-
// path
148-
ret = this._ignorePathCasing(uri1) ? compareIgnoreCase(uri1.path, uri2.path) : strCompare(uri1.path, uri2.path);
149-
// query
150-
if (ret === 0) {
151-
ret = strCompare(uri1.query, uri2.query);
152-
// fragment
153-
if (ret === 0 && !ignoreFragment) {
154-
ret = strCompare(uri1.fragment, uri2.fragment);
155-
}
156-
}
157-
}
141+
if (uri1 === uri2) {
142+
return 0;
158143
}
159-
return ret;
160-
}
161-
162-
getComparisonKey(uri: URI, ignoreFragment: boolean = false): string {
163-
return uri.with({
164-
path: this._ignorePathCasing(uri) ? uri.path.toLowerCase() : undefined,
165-
fragment: ignoreFragment ? null : undefined
166-
}).toString();
144+
return strCompare(this.getComparisonKey(uri1, ignoreFragment), this.getComparisonKey(uri2, ignoreFragment));
167145
}
168146

169147
isEqual(uri1: URI | undefined, uri2: URI | undefined, ignoreFragment: boolean = false): boolean {
@@ -173,15 +151,14 @@ export class ExtUri implements IExtUri {
173151
if (!uri1 || !uri2) {
174152
return false;
175153
}
176-
if (uri1.scheme !== uri2.scheme || !isEqualAuthority(uri1.authority, uri2.authority)) {
177-
return false;
178-
}
179-
if (uri1.toString() === uri2.toString()) {
180-
// TODO@jrieken see https://github.com/microsoft/vscode/issues/98934
181-
return true;
182-
}
183-
const p1 = uri1.path, p2 = uri2.path;
184-
return (p1 === p2 || this._ignorePathCasing(uri1) && equalsIgnoreCase(p1, p2)) && uri1.query === uri2.query && (ignoreFragment || uri1.fragment === uri2.fragment);
154+
return this.getComparisonKey(uri1, ignoreFragment) === this.getComparisonKey(uri2, ignoreFragment);
155+
}
156+
157+
getComparisonKey(uri: URI, ignoreFragment: boolean = false): string {
158+
return uri.with({
159+
path: this._ignorePathCasing(uri) ? uri.path.toLowerCase() : undefined,
160+
fragment: ignoreFragment ? null : undefined
161+
}).toString();
185162
}
186163

187164
isEqualOrParent(base: URI, parentCandidate: URI, ignoreFragment: boolean = false): boolean {

0 commit comments

Comments
 (0)