[css] path completion sometimes only works for one folder level. Fixes #46722

This commit is contained in:
Martin Aeschlimann
2018-03-29 15:20:30 +02:00
parent f50b6d7f13
commit 11f5d549db
5 changed files with 94 additions and 25 deletions

View File

@@ -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 => {