Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
124a368e
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
124a368e
编写于
5月 13, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
don't change/invent path when comparing uris,
https://github.com/microsoft/vscode/issues/93368
上级
1e6b94d7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
27 addition
and
19 deletion
+27
-19
src/vs/base/common/resources.ts
src/vs/base/common/resources.ts
+21
-15
src/vs/base/test/common/resources.test.ts
src/vs/base/test/common/resources.test.ts
+6
-4
未找到文件。
src/vs/base/common/resources.ts
浏览文件 @
124a368e
...
...
@@ -27,22 +27,26 @@ function _hasToIgnoreCase(resource: URI | undefined): boolean {
/**
* Creates a key from a resource URI to be used to resource comparison and for resource maps.
*
* **!!! This function is not compatible with URI.toString() !!!**
* @param resource Uri
* @param caseInsensitivePath Ignore casing when comparing path component (defaults mostly to `true`)
* @param ignoreFragment Ignore the fragment (defaults to `false`)
*/
export
function
getComparisonKey
(
resource
:
URI
,
caseInsensitivePath
=
_hasToIgnoreCase
(
resource
),
ignoreFragment
:
boolean
=
false
):
string
{
let
path
=
resource
.
path
||
'
/
'
;
// VERY bogous as it changes the uri
if
(
caseInsensitivePath
)
{
path
=
path
.
toLowerCase
();
}
return
resource
.
with
({
path
,
fragment
:
ignoreFragment
?
null
:
undefined
}).
toString
();
export
function
getComparisonKey
(
resource
:
URI
,
caseInsensitivePath
:
boolean
=
_hasToIgnoreCase
(
resource
),
ignoreFragment
:
boolean
=
false
):
string
{
return
resource
.
with
({
path
:
caseInsensitivePath
?
resource
.
path
.
toLowerCase
()
:
undefined
,
fragment
:
ignoreFragment
?
null
:
undefined
}).
toString
();
}
/**
* Tests whether two
resources are the same.
* Tests whether two
uris are equal
*
* **!!! This function is not compatible with uriA.toString() === uriB.toString() !!!**
* @param first Uri
* @param second Uri
* @param caseInsensitivePath Ignore casing when comparing path component (defaults mostly to `true`)
* @param ignoreFragment Ignore the fragment (defaults to `false`)
*/
export
function
isEqual
(
first
:
URI
|
undefined
,
second
:
URI
|
undefined
,
caseInsensitivePath
=
_hasToIgnoreCase
(
first
),
ignoreFragment
:
boolean
=
false
):
boolean
{
export
function
isEqual
(
first
:
URI
|
undefined
,
second
:
URI
|
undefined
,
caseInsensitivePath
:
boolean
=
_hasToIgnoreCase
(
first
),
ignoreFragment
:
boolean
=
false
):
boolean
{
if
(
first
===
second
)
{
return
true
;
}
...
...
@@ -52,23 +56,25 @@ export function isEqual(first: URI | undefined, second: URI | undefined, caseIns
if
(
first
.
scheme
!==
second
.
scheme
||
!
isEqualAuthority
(
first
.
authority
,
second
.
authority
))
{
return
false
;
}
const
p1
=
first
.
path
||
'
/
'
,
p2
=
second
.
path
||
'
/
'
;
const
p1
=
first
.
path
,
p2
=
second
.
path
;
return
(
p1
===
p2
||
caseInsensitivePath
&&
equalsIgnoreCase
(
p1
,
p2
))
&&
first
.
query
===
second
.
query
&&
(
ignoreFragment
||
first
.
fragment
===
second
.
fragment
);
}
/**
* Tests whether a `candidate` URI is a parent or equal of a given `base` URI.
*
URI queries must match, fragments are ignored.
*
* @param base A uri which is "longer"
* @param parentCandidate A uri which is "shorter" then `base`
* @param caseInsensitivePath Ignore casing when comparing path component (defaults mostly to `true`)
* @param ignoreFragment Ignore the fragment (defaults to `false`)
*/
export
function
isEqualOrParent
(
base
:
URI
,
parentCandidate
:
URI
,
ignoreCase
=
_hasToIgnoreCase
(
base
),
ignoreFragment
:
boolean
=
false
):
boolean
{
export
function
isEqualOrParent
(
base
:
URI
,
parentCandidate
:
URI
,
caseInsensitivePath
:
boolean
=
_hasToIgnoreCase
(
base
),
ignoreFragment
:
boolean
=
false
):
boolean
{
if
(
base
.
scheme
===
parentCandidate
.
scheme
)
{
if
(
base
.
scheme
===
Schemas
.
file
)
{
return
extpath
.
isEqualOrParent
(
originalFSPath
(
base
),
originalFSPath
(
parentCandidate
),
ignoreCase
)
&&
base
.
query
===
parentCandidate
.
query
&&
(
ignoreFragment
||
base
.
fragment
===
parentCandidate
.
fragment
);
return
extpath
.
isEqualOrParent
(
originalFSPath
(
base
),
originalFSPath
(
parentCandidate
),
caseInsensitivePath
)
&&
base
.
query
===
parentCandidate
.
query
&&
(
ignoreFragment
||
base
.
fragment
===
parentCandidate
.
fragment
);
}
if
(
isEqualAuthority
(
base
.
authority
,
parentCandidate
.
authority
))
{
return
extpath
.
isEqualOrParent
(
base
.
path
||
'
/
'
,
parentCandidate
.
path
||
'
/
'
,
ignoreCase
,
'
/
'
)
&&
base
.
query
===
parentCandidate
.
query
&&
(
ignoreFragment
||
base
.
fragment
===
parentCandidate
.
fragment
);
return
extpath
.
isEqualOrParent
(
base
.
path
,
parentCandidate
.
path
,
caseInsensitivePath
,
'
/
'
)
&&
base
.
query
===
parentCandidate
.
query
&&
(
ignoreFragment
||
base
.
fragment
===
parentCandidate
.
fragment
);
}
}
return
false
;
...
...
src/vs/base/test/common/resources.test.ts
浏览文件 @
124a368e
...
...
@@ -254,14 +254,14 @@ suite('Resources', () => {
assertRelativePath
(
URI
.
parse
(
'
foo://a/foo
'
),
URI
.
parse
(
'
foo://a/foo/bar/goo
'
),
'
bar/goo
'
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/
'
),
URI
.
parse
(
'
foo://a/foo/bar/goo
'
),
'
foo/bar/goo
'
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/foo/xoo
'
),
URI
.
parse
(
'
foo://a/foo/bar
'
),
'
../bar
'
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/foo/xoo/yoo
'
),
URI
.
parse
(
'
foo://a
'
),
'
../../..
'
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/foo/xoo/yoo
'
),
URI
.
parse
(
'
foo://a
'
),
'
../../..
'
,
true
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/foo
'
),
URI
.
parse
(
'
foo://a/foo/
'
),
''
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/foo/
'
),
URI
.
parse
(
'
foo://a/foo
'
),
''
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/foo/
'
),
URI
.
parse
(
'
foo://a/foo/
'
),
''
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/foo
'
),
URI
.
parse
(
'
foo://a/foo
'
),
''
);
assertRelativePath
(
URI
.
parse
(
'
foo://a
'
),
URI
.
parse
(
'
foo://a
'
),
''
);
assertRelativePath
(
URI
.
parse
(
'
foo://a
'
),
URI
.
parse
(
'
foo://a
'
),
''
,
true
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/
'
),
URI
.
parse
(
'
foo://a/
'
),
''
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/
'
),
URI
.
parse
(
'
foo://a
'
),
''
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/
'
),
URI
.
parse
(
'
foo://a
'
),
''
,
true
);
assertRelativePath
(
URI
.
parse
(
'
foo://a/foo?q
'
),
URI
.
parse
(
'
foo://a/foo/bar#h
'
),
'
bar
'
,
true
);
assertRelativePath
(
URI
.
parse
(
'
foo://
'
),
URI
.
parse
(
'
foo://a/b
'
),
undefined
);
assertRelativePath
(
URI
.
parse
(
'
foo://a2/b
'
),
URI
.
parse
(
'
foo://a/b
'
),
undefined
);
...
...
@@ -372,7 +372,9 @@ suite('Resources', () => {
assertIsEqual
(
fileURI
,
fileURI3
,
true
,
false
);
assertIsEqual
(
URI
.
parse
(
'
foo://server
'
),
URI
.
parse
(
'
foo://server/
'
),
true
,
true
);
assertIsEqual
(
URI
.
parse
(
'
file://server
'
),
URI
.
parse
(
'
file://server/
'
),
true
,
true
);
assertIsEqual
(
URI
.
parse
(
'
http://server
'
),
URI
.
parse
(
'
http://server/
'
),
true
,
true
);
assertIsEqual
(
URI
.
parse
(
'
foo://server
'
),
URI
.
parse
(
'
foo://server/
'
),
true
,
false
);
// only selected scheme have / as the default path
assertIsEqual
(
URI
.
parse
(
'
foo://server/foo
'
),
URI
.
parse
(
'
foo://server/foo/
'
),
true
,
false
);
assertIsEqual
(
URI
.
parse
(
'
foo://server/foo
'
),
URI
.
parse
(
'
foo://server/foo?
'
),
true
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录