Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
732d7f3c
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,发现更多精彩内容 >>
提交
732d7f3c
编写于
3月 20, 2017
作者:
J
Johannes Rieken
提交者:
GitHub
3月 20, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22888 from Microsoft/joh/21684
Uri.file fix
上级
41552b17
d4075635
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
102 addition
and
86 deletion
+102
-86
src/vs/base/common/uri.ts
src/vs/base/common/uri.ts
+9
-5
src/vs/base/test/common/uri.test.ts
src/vs/base/test/common/uri.test.ts
+78
-66
src/vs/workbench/parts/search/test/common/searchResult.test.ts
...s/workbench/parts/search/test/common/searchResult.test.ts
+15
-15
未找到文件。
src/vs/base/common/uri.ts
浏览文件 @
732d7f3c
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
platform
=
require
(
'
vs/base/common/platform
'
)
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
function
_encode
(
ch
:
string
):
string
{
...
...
@@ -152,7 +152,7 @@ export default class URI {
return
this
;
}
let
{
scheme
,
authority
,
path
,
query
,
fragment
}
=
change
;
let
{
scheme
,
authority
,
path
,
query
,
fragment
}
=
change
;
if
(
scheme
===
void
0
)
{
scheme
=
this
.
scheme
;
}
else
if
(
scheme
===
null
)
{
...
...
@@ -217,8 +217,12 @@ export default class URI {
const
ret
=
new
URI
();
ret
.
_scheme
=
'
file
'
;
// normalize to fwd-slashes
path
=
path
.
replace
(
/
\\
/g
,
URI
.
_slash
);
// normalize to fwd-slashes on windows,
// on other systems bwd-slaches are valid
// filename character, eg /f\oo/ba\r.txt
if
(
platform
.
isWindows
)
{
path
=
path
.
replace
(
/
\\
/g
,
URI
.
_slash
);
}
// check for authority as used in UNC shares
// or use the path as given
...
...
@@ -325,7 +329,7 @@ export default class URI {
const
parts
:
string
[]
=
[];
let
{
scheme
,
authority
,
path
,
query
,
fragment
}
=
uri
;
let
{
scheme
,
authority
,
path
,
query
,
fragment
}
=
uri
;
if
(
scheme
)
{
parts
.
push
(
scheme
,
'
:
'
);
}
...
...
src/vs/base/test/common/uri.test.ts
浏览文件 @
732d7f3c
...
...
@@ -7,6 +7,8 @@
import
*
as
assert
from
'
assert
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
normalize
}
from
'
vs/base/common/paths
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
suite
(
'
URI
'
,
()
=>
{
test
(
'
file#toString
'
,
()
=>
{
...
...
@@ -14,18 +16,36 @@ suite('URI', () => {
assert
.
equal
(
URI
.
file
(
'
C:/win/path
'
).
toString
(),
'
file:///c%3A/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
c:/win/path/
'
).
toString
(),
'
file:///c%3A/win/path/
'
);
assert
.
equal
(
URI
.
file
(
'
/c:/win/path
'
).
toString
(),
'
file:///c%3A/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
c:
\\
win
\\
path
'
).
toString
(),
'
file:///c%3A/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
c:
\\
win/path
'
).
toString
(),
'
file:///c%3A/win/path
'
);
});
test
(
'
file#path
'
,
()
=>
{
assert
.
equal
(
URI
.
file
(
'
c:/win/path
'
).
fsPath
.
replace
(
/
\\
/g
,
'
/
'
),
'
c:/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
c:/win/path/
'
).
fsPath
.
replace
(
/
\\
/g
,
'
/
'
),
'
c:/win/path/
'
);
assert
.
equal
(
URI
.
file
(
'
C:/win/path
'
).
fsPath
.
replace
(
/
\\
/g
,
'
/
'
),
'
c:/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
/c:/win/path
'
).
fsPath
.
replace
(
/
\\
/g
,
'
/
'
),
'
c:/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
./c/win/path
'
).
fsPath
.
replace
(
/
\\
/g
,
'
/
'
),
'
/./c/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
c:
\\
win
\\
path
'
).
fsPath
.
replace
(
/
\\
/g
,
'
/
'
),
'
c:/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
c:
\\
win/path
'
).
fsPath
.
replace
(
/
\\
/g
,
'
/
'
),
'
c:/win/path
'
);
test
(
'
URI.file (win-special)
'
,
()
=>
{
if
(
isWindows
)
{
assert
.
equal
(
URI
.
file
(
'
c:
\\
win
\\
path
'
).
toString
(),
'
file:///c%3A/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
c:
\\
win/path
'
).
toString
(),
'
file:///c%3A/win/path
'
);
}
else
{
assert
.
equal
(
URI
.
file
(
'
c:
\\
win
\\
path
'
).
toString
(),
'
file:///c%3A%5Cwin%5Cpath
'
);
assert
.
equal
(
URI
.
file
(
'
c:
\\
win/path
'
).
toString
(),
'
file:///c%3A%5Cwin/path
'
);
}
});
test
(
'
file#fsPath (win-special)
'
,
()
=>
{
if
(
isWindows
)
{
assert
.
equal
(
URI
.
file
(
'
c:
\\
win
\\
path
'
).
fsPath
,
'
c:
\\
win
\\
path
'
);
assert
.
equal
(
URI
.
file
(
'
c:
\\
win/path
'
).
fsPath
,
'
c:
\\
win
\\
path
'
);
assert
.
equal
(
URI
.
file
(
'
c:/win/path
'
).
fsPath
,
'
c:
\\
win
\\
path
'
);
assert
.
equal
(
URI
.
file
(
'
c:/win/path/
'
).
fsPath
,
'
c:
\\
win
\\
path
\\
'
);
assert
.
equal
(
URI
.
file
(
'
C:/win/path
'
).
fsPath
,
'
c:
\\
win
\\
path
'
);
assert
.
equal
(
URI
.
file
(
'
/c:/win/path
'
).
fsPath
,
'
c:
\\
win
\\
path
'
);
assert
.
equal
(
URI
.
file
(
'
./c/win/path
'
).
fsPath
,
'
\\
.
\\
c
\\
win
\\
path
'
);
}
else
{
assert
.
equal
(
URI
.
file
(
'
c:/win/path
'
).
fsPath
,
'
c:/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
c:/win/path/
'
).
fsPath
,
'
c:/win/path/
'
);
assert
.
equal
(
URI
.
file
(
'
C:/win/path
'
).
fsPath
,
'
c:/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
/c:/win/path
'
).
fsPath
,
'
c:/win/path
'
);
assert
.
equal
(
URI
.
file
(
'
./c/win/path
'
).
fsPath
,
'
/./c/win/path
'
);
}
});
test
(
'
URI#fsPath - no `fsPath` when no `path`
'
,
()
=>
{
...
...
@@ -244,69 +264,61 @@ suite('URI', () => {
assert
.
throws
(()
=>
URI
.
parse
(
'
file:////shares/files/p.cs
'
));
});
test
(
'
URI#file
'
,
()
=>
{
var
value
=
URI
.
file
(
'
\\\\
shäres
\\
path
\\
c#
\\
plugin.json
'
);
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
authority
,
'
shäres
'
);
assert
.
equal
(
value
.
path
,
'
/path/c#/plugin.json
'
);
assert
.
equal
(
value
.
fragment
,
''
);
assert
.
equal
(
value
.
query
,
''
);
assert
.
equal
(
value
.
toString
(),
'
file://sh%C3%A4res/path/c%23/plugin.json
'
);
// identity toString -> parse -> toString
value
=
URI
.
parse
(
value
.
toString
());
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
authority
,
'
shäres
'
);
assert
.
equal
(
value
.
path
,
'
/path/c#/plugin.json
'
);
assert
.
equal
(
value
.
fragment
,
''
);
assert
.
equal
(
value
.
query
,
''
);
assert
.
equal
(
value
.
toString
(),
'
file://sh%C3%A4res/path/c%23/plugin.json
'
);
value
=
URI
.
file
(
'
\\\\
localhost
\\
c$
\\
GitDevelopment
\\
express
'
);
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
path
,
'
/c$/GitDevelopment/express
'
);
assert
.
equal
(
value
.
fsPath
,
normalize
(
'
//localhost/c$/GitDevelopment/express
'
,
true
));
assert
.
equal
(
value
.
query
,
''
);
assert
.
equal
(
value
.
fragment
,
''
);
assert
.
equal
(
value
.
toString
(),
'
file://localhost/c%24/GitDevelopment/express
'
);
value
=
URI
.
file
(
'
c:
\\
test with %
\\
path
'
);
assert
.
equal
(
value
.
path
,
'
/c:/test with %/path
'
);
assert
.
equal
(
value
.
toString
(),
'
file:///c%3A/test%20with%20%25/path
'
);
value
=
URI
.
file
(
'
c:
\\
test with %25
\\
path
'
);
assert
.
equal
(
value
.
path
,
'
/c:/test with %25/path
'
);
assert
.
equal
(
value
.
toString
(),
'
file:///c%3A/test%20with%20%2525/path
'
);
value
=
URI
.
file
(
'
c:
\\
test with %25
\\
c#code
'
);
assert
.
equal
(
value
.
path
,
'
/c:/test with %25/c#code
'
);
assert
.
equal
(
value
.
toString
(),
'
file:///c%3A/test%20with%20%2525/c%23code
'
);
value
=
URI
.
file
(
'
\\\\
shares
'
);
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
authority
,
'
shares
'
);
assert
.
equal
(
value
.
path
,
'
/
'
);
// slash is always there
test
(
'
URI#file, win-speciale
'
,
()
=>
{
if
(
isWindows
)
{
var
value
=
URI
.
file
(
'
c:
\\
test
\\
drive
'
);
assert
.
equal
(
value
.
path
,
'
/c:/test/drive
'
);
assert
.
equal
(
value
.
toString
(),
'
file:///c%3A/test/drive
'
);
value
=
URI
.
file
(
'
\\\\
shäres
\\
path
\\
c#
\\
plugin.json
'
);
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
authority
,
'
shäres
'
);
assert
.
equal
(
value
.
path
,
'
/path/c#/plugin.json
'
);
assert
.
equal
(
value
.
fragment
,
''
);
assert
.
equal
(
value
.
query
,
''
);
assert
.
equal
(
value
.
toString
(),
'
file://sh%C3%A4res/path/c%23/plugin.json
'
);
value
=
URI
.
file
(
'
\\\\
localhost
\\
c$
\\
GitDevelopment
\\
express
'
);
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
path
,
'
/c$/GitDevelopment/express
'
);
assert
.
equal
(
value
.
fsPath
,
'
\\\\
localhost
\\
c$
\\
GitDevelopment
\\
express
'
);
assert
.
equal
(
value
.
query
,
''
);
assert
.
equal
(
value
.
fragment
,
''
);
assert
.
equal
(
value
.
toString
(),
'
file://localhost/c%24/GitDevelopment/express
'
);
value
=
URI
.
file
(
'
c:
\\
test with %
\\
path
'
);
assert
.
equal
(
value
.
path
,
'
/c:/test with %/path
'
);
assert
.
equal
(
value
.
toString
(),
'
file:///c%3A/test%20with%20%25/path
'
);
value
=
URI
.
file
(
'
c:
\\
test with %25
\\
path
'
);
assert
.
equal
(
value
.
path
,
'
/c:/test with %25/path
'
);
assert
.
equal
(
value
.
toString
(),
'
file:///c%3A/test%20with%20%2525/path
'
);
value
=
URI
.
file
(
'
c:
\\
test with %25
\\
c#code
'
);
assert
.
equal
(
value
.
path
,
'
/c:/test with %25/c#code
'
);
assert
.
equal
(
value
.
toString
(),
'
file:///c%3A/test%20with%20%2525/c%23code
'
);
value
=
URI
.
file
(
'
\\\\
shares
'
);
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
authority
,
'
shares
'
);
assert
.
equal
(
value
.
path
,
'
/
'
);
// slash is always there
value
=
URI
.
file
(
'
\\\\
shares
\\
'
);
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
authority
,
'
shares
'
);
assert
.
equal
(
value
.
path
,
'
/
'
);
}
});
value
=
URI
.
file
(
'
\\\\
shares
\\
'
);
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
authority
,
'
shares
'
);
assert
.
equal
(
value
.
path
,
'
/
'
);
test
(
'
URI#file, no path-is-uri check
'
,
()
=>
{
// we don't complain here
value
=
URI
.
file
(
'
file://path/to/file
'
);
let
value
=
URI
.
file
(
'
file://path/to/file
'
);
assert
.
equal
(
value
.
scheme
,
'
file
'
);
assert
.
equal
(
value
.
authority
,
''
);
assert
.
equal
(
value
.
path
,
'
/file://path/to/file
'
);
});
test
(
'
URI#file, auto-slash windows drive letter
'
,
()
=>
{
var
value
=
URI
.
file
(
'
c:
\\
test
\\
drive
'
);
assert
.
equal
(
value
.
path
,
'
/c:/test/drive
'
);
assert
.
equal
(
value
.
toString
(),
'
file:///c%3A/test/drive
'
);
});
test
(
'
URI#file, always slash
'
,
()
=>
{
var
value
=
URI
.
file
(
'
a.file
'
);
...
...
@@ -419,4 +431,4 @@ suite('URI', () => {
// }
// console.profileEnd();
});
});
\ No newline at end of file
});
src/vs/workbench/parts/search/test/common/searchResult.test.ts
浏览文件 @
732d7f3c
...
...
@@ -32,18 +32,18 @@ suite('SearchResult', () => {
});
test
(
'
Line Match
'
,
function
()
{
let
fileMatch
=
aFileMatch
(
'
folder
\\
file.txt
'
,
null
);
let
fileMatch
=
aFileMatch
(
'
folder
/
file.txt
'
,
null
);
let
lineMatch
=
new
Match
(
fileMatch
,
'
foo bar
'
,
1
,
0
,
3
);
assert
.
equal
(
lineMatch
.
text
(),
'
foo bar
'
);
assert
.
equal
(
lineMatch
.
range
().
startLineNumber
,
2
);
assert
.
equal
(
lineMatch
.
range
().
endLineNumber
,
2
);
assert
.
equal
(
lineMatch
.
range
().
startColumn
,
1
);
assert
.
equal
(
lineMatch
.
range
().
endColumn
,
4
);
assert
.
equal
(
'
file:///
c%3A/
folder/file.txt>1>0foo
'
,
lineMatch
.
id
());
assert
.
equal
(
'
file:///folder/file.txt>1>0foo
'
,
lineMatch
.
id
());
});
test
(
'
Line Match - Remove
'
,
function
()
{
let
fileMatch
=
aFileMatch
(
'
folder
\\
file.txt
'
,
aSearchResult
(),
...[{
let
fileMatch
=
aFileMatch
(
'
folder
/
file.txt
'
,
aSearchResult
(),
...[{
preview
:
'
foo bar
'
,
lineNumber
:
1
,
offsetAndLengths
:
[[
0
,
3
]]
...
...
@@ -54,19 +54,19 @@ suite('SearchResult', () => {
});
test
(
'
File Match
'
,
function
()
{
let
fileMatch
=
aFileMatch
(
'
folder
\\
file.txt
'
);
let
fileMatch
=
aFileMatch
(
'
folder
/
file.txt
'
);
assert
.
equal
(
fileMatch
.
matches
(),
0
);
assert
.
equal
(
fileMatch
.
resource
().
toString
(),
'
file:///
c%3A/
folder/file.txt
'
);
assert
.
equal
(
fileMatch
.
resource
().
toString
(),
'
file:///folder/file.txt
'
);
assert
.
equal
(
fileMatch
.
name
(),
'
file.txt
'
);
fileMatch
=
aFileMatch
(
'
file.txt
'
);
assert
.
equal
(
fileMatch
.
matches
(),
0
);
assert
.
equal
(
fileMatch
.
resource
().
toString
(),
'
file:///
c%3A/
file.txt
'
);
assert
.
equal
(
fileMatch
.
resource
().
toString
(),
'
file:///file.txt
'
);
assert
.
equal
(
fileMatch
.
name
(),
'
file.txt
'
);
});
test
(
'
File Match: Select an existing match
'
,
function
()
{
let
testObject
=
aFileMatch
(
'
folder
\\
file.txt
'
,
aSearchResult
(),
...[{
let
testObject
=
aFileMatch
(
'
folder
/
file.txt
'
,
aSearchResult
(),
...[{
preview
:
'
foo
'
,
lineNumber
:
1
,
offsetAndLengths
:
[[
0
,
3
]]
...
...
@@ -82,7 +82,7 @@ suite('SearchResult', () => {
});
test
(
'
File Match: Select non existing match
'
,
function
()
{
let
testObject
=
aFileMatch
(
'
folder
\\
file.txt
'
,
aSearchResult
(),
...[{
let
testObject
=
aFileMatch
(
'
folder
/
file.txt
'
,
aSearchResult
(),
...[{
preview
:
'
foo
'
,
lineNumber
:
1
,
offsetAndLengths
:
[[
0
,
3
]]
...
...
@@ -100,7 +100,7 @@ suite('SearchResult', () => {
});
test
(
'
File Match: isSelected return true for selected match
'
,
function
()
{
let
testObject
=
aFileMatch
(
'
folder
\\
file.txt
'
,
aSearchResult
(),
...[{
let
testObject
=
aFileMatch
(
'
folder
/
file.txt
'
,
aSearchResult
(),
...[{
preview
:
'
foo
'
,
lineNumber
:
1
,
offsetAndLengths
:
[[
0
,
3
]]
...
...
@@ -116,7 +116,7 @@ suite('SearchResult', () => {
});
test
(
'
File Match: isSelected return false for un-selected match
'
,
function
()
{
let
testObject
=
aFileMatch
(
'
folder
\\
file.txt
'
,
aSearchResult
(),
...[{
let
testObject
=
aFileMatch
(
'
folder
/
file.txt
'
,
aSearchResult
(),
...[{
preview
:
'
foo
'
,
lineNumber
:
1
,
offsetAndLengths
:
[[
0
,
3
]]
...
...
@@ -132,7 +132,7 @@ suite('SearchResult', () => {
});
test
(
'
File Match: unselect
'
,
function
()
{
let
testObject
=
aFileMatch
(
'
folder
\\
file.txt
'
,
aSearchResult
(),
...[{
let
testObject
=
aFileMatch
(
'
folder
/
file.txt
'
,
aSearchResult
(),
...[{
preview
:
'
foo
'
,
lineNumber
:
1
,
offsetAndLengths
:
[[
0
,
3
]]
...
...
@@ -149,7 +149,7 @@ suite('SearchResult', () => {
});
test
(
'
File Match: unselect when not selected
'
,
function
()
{
let
testObject
=
aFileMatch
(
'
folder
\\
file.txt
'
,
aSearchResult
(),
...[{
let
testObject
=
aFileMatch
(
'
folder
/
file.txt
'
,
aSearchResult
(),
...[{
preview
:
'
foo
'
,
lineNumber
:
1
,
offsetAndLengths
:
[[
0
,
3
]]
...
...
@@ -166,7 +166,7 @@ suite('SearchResult', () => {
test
(
'
Alle Drei Zusammen
'
,
function
()
{
let
searchResult
=
instantiationService
.
createInstance
(
SearchResult
,
null
);
let
fileMatch
=
aFileMatch
(
'
far
\\
boo
'
,
searchResult
);
let
fileMatch
=
aFileMatch
(
'
far
/
boo
'
,
searchResult
);
let
lineMatch
=
new
Match
(
fileMatch
,
'
foo bar
'
,
1
,
0
,
3
);
assert
(
lineMatch
.
parent
()
===
fileMatch
);
...
...
@@ -360,7 +360,7 @@ suite('SearchResult', () => {
function
aFileMatch
(
path
:
string
,
searchResult
?:
SearchResult
,
...
lineMatches
:
ILineMatch
[]):
FileMatch
{
let
rawMatch
:
IFileMatch
=
{
resource
:
URI
.
file
(
'
C:
\\
'
+
path
),
resource
:
URI
.
file
(
'
/
'
+
path
),
lineMatches
:
lineMatches
};
return
instantiationService
.
createInstance
(
FileMatch
,
null
,
searchResult
,
rawMatch
);
...
...
@@ -383,4 +383,4 @@ suite('SearchResult', () => {
instantiationService
.
stub
(
IConfigurationService
,
new
TestConfigurationService
());
return
instantiationService
.
createInstance
(
ModelServiceImpl
);
}
});
\ No newline at end of file
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录