Skip to content

Commit 9b3371e

Browse files
authored
Fix path sep for markdown drop on windows (microsoft#167862)
Fixes microsoft#167824
1 parent 55d6b17 commit 9b3371e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

extensions/markdown-language-features/src/languageFeatures/dropIntoEditor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ export function createUriListSnippet(document: vscode.TextDocument, uris: readon
103103
function getMdPath(dir: vscode.Uri | undefined, file: vscode.Uri) {
104104
if (dir && dir.scheme === file.scheme && dir.authority === file.authority) {
105105
if (file.scheme === Schemes.file) {
106-
// On windows, we must use the native `path.resolve` to generate the relative path
106+
// On windows, we must use the native `path.relative` to generate the relative path
107107
// so that drive-letters are resolved cast insensitively. However we then want to
108108
// convert back to a posix path to insert in to the document.
109-
return encodeURI(path.posix.normalize(path.relative(dir.fsPath, file.fsPath)));
109+
const relativePath = path.relative(dir.fsPath, file.fsPath);
110+
return encodeURI(path.posix.normalize(relativePath.split(path.sep).join(path.posix.sep)));
110111
}
111112

112113
return encodeURI(path.posix.relative(dir.path, file.path));

0 commit comments

Comments
 (0)