mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Use un-encoded file paths are rename placeholder
This commit is contained in:
parent
7b1168660a
commit
59b6227bf3
|
@ -37,6 +37,14 @@ export interface MdWorkspaceEdit {
|
|||
readonly fileRenames?: ReadonlyArray<MdFileRenameEdit>;
|
||||
}
|
||||
|
||||
function tryDecodeUri(str: string): string {
|
||||
try {
|
||||
return decodeURI(str);
|
||||
} catch {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
export class MdRenameProvider extends Disposable implements vscode.RenameProvider {
|
||||
|
||||
private cachedRefs?: {
|
||||
|
@ -98,7 +106,7 @@ export class MdRenameProvider extends Disposable implements vscode.RenameProvide
|
|||
if (!range) {
|
||||
throw new Error(this.renameNotSupportedText);
|
||||
}
|
||||
return { range, placeholder: document.getText(range) };
|
||||
return { range, placeholder: tryDecodeUri(document.getText(range)) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -412,6 +412,16 @@ suite('markdown: rename', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('Path rename should use un-encoded paths as placeholder', async () => {
|
||||
const uri = workspacePath('sub', 'doc with spaces.md');
|
||||
const doc = new InMemoryDocument(uri, joinLines(
|
||||
`[text](/sub/doc%20with%20spaces.md)`,
|
||||
));
|
||||
|
||||
const info = await prepareRename(doc, new vscode.Position(0, 10), new InMemoryWorkspaceMarkdownDocuments([doc]));
|
||||
assert.strictEqual(info!.placeholder, '/sub/doc with spaces.md');
|
||||
});
|
||||
|
||||
test('Path rename should encode paths', async () => {
|
||||
const uri = workspacePath('sub', 'doc.md');
|
||||
const doc = new InMemoryDocument(uri, joinLines(
|
||||
|
|
Loading…
Reference in a new issue