Escape spaces in file names for md suggestions

Fixes #142838
This commit is contained in:
Matt Bierner
2022-02-11 16:17:58 -08:00
parent 5b52f9a9d0
commit 7f5be63be9
3 changed files with 10 additions and 1 deletions

View File

@@ -275,7 +275,7 @@ export class PathCompletionProvider implements vscode.CompletionItemProvider {
const isDir = type === vscode.FileType.Directory;
yield {
label: isDir ? name + '/' : name,
label: isDir ? encodeURIComponent(name) + '/' : encodeURIComponent(name),
kind: isDir ? vscode.CompletionItemKind.Folder : vscode.CompletionItemKind.File,
range: {
inserting: insertRange,

View File

@@ -143,4 +143,12 @@ suite('Markdown path completion provider', () => {
assert.ok(completions.some(x => x.label === 'b.md'), 'Has b.md file completion');
assert.ok(completions.some(x => x.label === 'sub/'), 'Has sub folder completion');
});
test('Should escape spaces in path names', async () => {
const completions = await getCompletionsAtCursor(workspaceFile('new.md'), joinLines(
`[](./sub/${CURSOR})`
));
assert.ok(completions.some(x => x.label === 'file%20with%20space.md'), 'Has encoded path completion');
});
});