This commit is contained in:
Pine Wu
2018-04-11 15:24:27 -07:00
parent 263ab1fb98
commit 57cba59b0a
3 changed files with 21 additions and 4 deletions

View File

@@ -118,9 +118,9 @@ function pathToSuggestion(p: string, replaceRange: Range): CompletionItem {
if (isDir) {
return {
label: p,
label: escapePath(p),
kind: CompletionItemKind.Folder,
textEdit: TextEdit.replace(replaceRange, p),
textEdit: TextEdit.replace(replaceRange, escapePath(p)),
command: {
title: 'Suggest',
command: 'editor.action.triggerSuggest'
@@ -128,13 +128,18 @@ function pathToSuggestion(p: string, replaceRange: Range): CompletionItem {
};
} else {
return {
label: p,
label: escapePath(p),
kind: CompletionItemKind.File,
textEdit: TextEdit.replace(replaceRange, p)
textEdit: TextEdit.replace(replaceRange, escapePath(p))
};
}
}
// Escape https://www.w3.org/TR/CSS1/#url
function escapePath(p: string) {
return p.replace(/(\s|\(|\)|,|"|')/g, '\\$1');
}
function resolveWorkspaceRoot(activeDoc: TextDocument, workspaceFolders: WorkspaceFolder[]): string | undefined {
for (let i = 0; i < workspaceFolders.length; i++) {
if (startsWith(activeDoc.uri, workspaceFolders[i].uri)) {