Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
11f5d549
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,发现更多精彩内容 >>
提交
11f5d549
编写于
3月 29, 2018
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[css] path completion sometimes only works for one folder level. Fixes #46722
上级
f50b6d7f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
94 addition
and
25 deletion
+94
-25
extensions/css-language-features/server/src/pathCompletion.ts
...nsions/css-language-features/server/src/pathCompletion.ts
+4
-9
extensions/css-language-features/server/src/test/completion.test.ts
.../css-language-features/server/src/test/completion.test.ts
+34
-6
extensions/html-language-features/server/src/modes/pathCompletion.ts
...html-language-features/server/src/modes/pathCompletion.ts
+4
-9
extensions/html-language-features/server/src/test/completions.test.ts
...tml-language-features/server/src/test/completions.test.ts
+48
-1
extensions/html-language-features/server/src/test/pathCompletionFixtures/about/media/icon.pic
...rver/src/test/pathCompletionFixtures/about/media/icon.pic
+4
-0
未找到文件。
extensions/css-language-features/server/src/pathCompletion.ts
浏览文件 @
11f5d549
...
...
@@ -54,16 +54,11 @@ export function providePathSuggestions(value: string, range: Range, activeDocFsP
replaceRange
=
getReplaceRange
(
range
,
valueAfterLastSlash
);
}
let
parentDir
:
string
;
if
(
lastIndexOfSlash
===
-
1
)
{
parentDir
=
path
.
resolve
(
root
);
}
else
{
const
valueBeforeLastSlash
=
value
.
slice
(
0
,
lastIndexOfSlash
+
1
);
const
valueBeforeLastSlash
=
value
.
slice
(
0
,
lastIndexOfSlash
+
1
);
parentDir
=
startsWith
(
value
,
'
/
'
)
?
path
.
resolve
(
root
,
'
.
'
+
valueBeforeLastSlash
)
:
path
.
resolve
(
activeDocFsPath
,
'
..
'
,
valueBeforeLastSlash
);
}
const
parentDir
=
startsWith
(
value
,
'
/
'
)
?
path
.
resolve
(
root
,
'
.
'
+
valueBeforeLastSlash
)
:
path
.
resolve
(
activeDocFsPath
,
'
..
'
,
valueBeforeLastSlash
);
try
{
return
fs
.
readdirSync
(
parentDir
).
map
(
f
=>
{
...
...
extensions/css-language-features/server/src/test/completion.test.ts
浏览文件 @
11f5d549
...
...
@@ -41,7 +41,7 @@ suite('Completions', () => {
const
position
=
document
.
positionAt
(
offset
);
if
(
!
workspaceFolders
)
{
workspaceFolders
=
[{
name
:
'
x
'
,
uri
:
path
.
dirname
(
testUri
)
}];
workspaceFolders
=
[{
name
:
'
x
'
,
uri
:
testUri
.
substr
(
0
,
testUri
.
lastIndexOf
(
'
/
'
)
)
}];
}
let
participantResult
=
CompletionList
.
create
([]);
...
...
@@ -62,13 +62,14 @@ suite('Completions', () => {
}
test
(
'
CSS Path completion
'
,
function
()
{
let
testUri
=
Uri
.
file
(
path
.
resolve
(
__dirname
,
'
../../test/pathCompletionFixtures/about/about.css
'
)).
fsPath
;
let
testUri
=
Uri
.
file
(
path
.
resolve
(
__dirname
,
'
../../test/pathCompletionFixtures/about/about.css
'
)).
toString
();
let
folders
=
[{
name
:
'
x
'
,
uri
:
Uri
.
file
(
path
.
resolve
(
__dirname
,
'
../../test
'
)).
toString
()
}];
assertCompletions
(
'
html { background-image: url("./|")
'
,
{
items
:
[
{
label
:
'
about.html
'
,
resultText
:
'
html { background-image: url("./about.html")
'
}
]
},
testUri
);
},
testUri
,
folders
);
assertCompletions
(
`html { background-image: url('../|')`
,
{
items
:
[
...
...
@@ -76,7 +77,7 @@ suite('Completions', () => {
{
label
:
'
index.html
'
,
resultText
:
`html { background-image: url('../index.html')`
},
{
label
:
'
src/
'
,
resultText
:
`html { background-image: url('../src/')`
}
]
},
testUri
);
},
testUri
,
folders
);
assertCompletions
(
`html { background-image: url('../src/a|')`
,
{
items
:
[
...
...
@@ -84,12 +85,39 @@ suite('Completions', () => {
{
label
:
'
data/
'
,
resultText
:
`html { background-image: url('../src/data/')`
},
{
label
:
'
test.js
'
,
resultText
:
`html { background-image: url('../src/test.js')`
}
]
},
testUri
);
},
testUri
,
folders
);
assertCompletions
(
`html { background-image: url('../src/data/f|.asar')`
,
{
items
:
[
{
label
:
'
foo.asar
'
,
resultText
:
`html { background-image: url('../src/data/foo.asar')`
}
]
},
testUri
);
},
testUri
,
folders
);
assertCompletions
(
`html { background-image: url('|')`
,
{
items
:
[
{
label
:
'
about.css
'
,
resultText
:
`html { background-image: url('about.css')`
},
{
label
:
'
about.html
'
,
resultText
:
`html { background-image: url('about.html')`
},
]
},
testUri
,
folders
);
assertCompletions
(
`html { background-image: url('/|')`
,
{
items
:
[
{
label
:
'
pathCompletionFixtures/
'
,
resultText
:
`html { background-image: url('/pathCompletionFixtures/')`
}
]
},
testUri
,
folders
);
assertCompletions
(
`html { background-image: url('/pathCompletionFixtures/|')`
,
{
items
:
[
{
label
:
'
about/
'
,
resultText
:
`html { background-image: url('/pathCompletionFixtures/about/')`
},
{
label
:
'
index.html
'
,
resultText
:
`html { background-image: url('/pathCompletionFixtures/index.html')`
},
{
label
:
'
src/
'
,
resultText
:
`html { background-image: url('/pathCompletionFixtures/src/')`
}
]
},
testUri
,
folders
);
assertCompletions
(
`html { background-image: url("/|")`
,
{
items
:
[
{
label
:
'
pathCompletionFixtures/
'
,
resultText
:
`html { background-image: url("/pathCompletionFixtures/")`
}
]
},
testUri
,
folders
);
});
});
\ No newline at end of file
extensions/html-language-features/server/src/modes/pathCompletion.ts
浏览文件 @
11f5d549
...
...
@@ -69,16 +69,11 @@ function providePaths(valueBeforeCursor: string, activeDocFsPath: string, root?:
}
const
lastIndexOfSlash
=
valueBeforeCursor
.
lastIndexOf
(
'
/
'
);
let
parentDir
:
string
;
if
(
lastIndexOfSlash
===
-
1
)
{
parentDir
=
path
.
resolve
(
root
);
}
else
{
const
valueBeforeLastSlash
=
valueBeforeCursor
.
slice
(
0
,
lastIndexOfSlash
+
1
);
const
valueBeforeLastSlash
=
valueBeforeCursor
.
slice
(
0
,
lastIndexOfSlash
+
1
);
parentDir
=
startsWith
(
valueBeforeCursor
,
'
/
'
)
?
path
.
resolve
(
root
,
'
.
'
+
valueBeforeLastSlash
)
:
path
.
resolve
(
activeDocFsPath
,
'
..
'
,
valueBeforeLastSlash
);
}
const
parentDir
=
startsWith
(
valueBeforeCursor
,
'
/
'
)
?
path
.
resolve
(
root
,
'
.
'
+
valueBeforeLastSlash
)
:
path
.
resolve
(
activeDocFsPath
,
'
..
'
,
valueBeforeLastSlash
);
try
{
return
fs
.
readdirSync
(
parentDir
).
map
(
f
=>
{
...
...
extensions/html-language-features/server/src/test/completions.test.ts
浏览文件 @
11f5d549
...
...
@@ -166,6 +166,7 @@ suite('HTML Path Completion', () => {
});
test
(
'
Empty Path Value
'
,
()
=>
{
// document: index.html
testCompletionFor
(
'
<script src="|">
'
,
{
items
:
[
{
label
:
'
about/
'
,
resultText
:
'
<script src="about/">
'
},
...
...
@@ -173,8 +174,15 @@ suite('HTML Path Completion', () => {
{
label
:
'
src/
'
,
resultText
:
'
<script src="src/">
'
},
]
},
indexHtmlUri
);
// document: about.html
testCompletionFor
(
'
<script src="|">
'
,
{
items
:
[
{
label
:
'
about.css
'
,
resultText
:
'
<script src="about.css">
'
},
{
label
:
'
about.html
'
,
resultText
:
'
<script src="about.html">
'
},
{
label
:
'
media/
'
,
resultText
:
'
<script src="media/">
'
},
]
},
aboutHtmlUri
);
});
test
(
'
Incomplete Path
'
,
()
=>
{
testCompletionFor
(
'
<script src="/src/f|">
'
,
{
items
:
[
...
...
@@ -192,6 +200,7 @@ suite('HTML Path Completion', () => {
});
test
(
'
No leading dot or slash
'
,
()
=>
{
// document: index.html
testCompletionFor
(
'
<script src="s|">
'
,
{
items
:
[
{
label
:
'
about/
'
,
resultText
:
'
<script src="about/">
'
},
...
...
@@ -213,9 +222,31 @@ suite('HTML Path Completion', () => {
{
label
:
'
test.js
'
,
resultText
:
'
<script src="src/test.js">
'
},
]
},
indexHtmlUri
,
[
fixtureWorkspace
]);
// document: about.html
testCompletionFor
(
'
<script src="s|">
'
,
{
items
:
[
{
label
:
'
about.css
'
,
resultText
:
'
<script src="about.css">
'
},
{
label
:
'
about.html
'
,
resultText
:
'
<script src="about.html">
'
},
{
label
:
'
media/
'
,
resultText
:
'
<script src="media/">
'
},
]
},
aboutHtmlUri
,
[
fixtureWorkspace
]);
testCompletionFor
(
'
<script src="media/|">
'
,
{
items
:
[
{
label
:
'
icon.pic
'
,
resultText
:
'
<script src="media/icon.pic">
'
}
]
},
aboutHtmlUri
,
[
fixtureWorkspace
]);
testCompletionFor
(
'
<script src="media/f|">
'
,
{
items
:
[
{
label
:
'
icon.pic
'
,
resultText
:
'
<script src="media/icon.pic">
'
}
]
},
aboutHtmlUri
,
[
fixtureWorkspace
]);
});
test
(
'
Trigger completion in middle of path
'
,
()
=>
{
// document: index.html
testCompletionFor
(
'
<script src="src/f|eature.js">
'
,
{
items
:
[
{
label
:
'
feature.js
'
,
resultText
:
'
<script src="src/feature.js">
'
},
...
...
@@ -230,8 +261,24 @@ suite('HTML Path Completion', () => {
{
label
:
'
src/
'
,
resultText
:
'
<script src="src/">
'
},
]
},
indexHtmlUri
,
[
fixtureWorkspace
]);
// document: about.html
testCompletionFor
(
'
<script src="media/f|eature.js">
'
,
{
items
:
[
{
label
:
'
icon.pic
'
,
resultText
:
'
<script src="media/icon.pic">
'
}
]
},
aboutHtmlUri
,
[
fixtureWorkspace
]);
testCompletionFor
(
'
<script src="m|edia/feature.js">
'
,
{
items
:
[
{
label
:
'
about.css
'
,
resultText
:
'
<script src="about.css">
'
},
{
label
:
'
about.html
'
,
resultText
:
'
<script src="about.html">
'
},
{
label
:
'
media/
'
,
resultText
:
'
<script src="media/">
'
},
]
},
aboutHtmlUri
,
[
fixtureWorkspace
]);
});
test
(
'
Trigger completion in middle of path and with whitespaces
'
,
()
=>
{
testCompletionFor
(
'
<script src="./| about/about.html>
'
,
{
items
:
[
...
...
extensions/html-language-features/server/src/test/pathCompletionFixtures/about/media/icon.pic
0 → 100644
浏览文件 @
11f5d549
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录