@@ -80,9 +80,7 @@ export function createUriListSnippet(document: vscode.TextDocument, uris: readon
80
80
81
81
const snippet = new vscode . SnippetString ( ) ;
82
82
uris . forEach ( ( uri , i ) => {
83
- const mdPath = dir && dir . scheme === uri . scheme && dir . authority === uri . authority
84
- ? encodeURI ( path . posix . relative ( dir . path , uri . path ) )
85
- : uri . toString ( false ) ;
83
+ const mdPath = getMdPath ( dir , uri ) ;
86
84
87
85
const ext = URI . Utils . extname ( uri ) . toLowerCase ( ) . replace ( '.' , '' ) ;
88
86
const insertAsImage = typeof options ?. insertAsImage === 'undefined' ? imageFileExtensions . has ( ext ) : ! ! options . insertAsImage ;
@@ -102,6 +100,21 @@ export function createUriListSnippet(document: vscode.TextDocument, uris: readon
102
100
return snippet ;
103
101
}
104
102
103
+ function getMdPath ( dir : vscode . Uri | undefined , file : vscode . Uri ) {
104
+ if ( dir && dir . scheme === file . scheme && dir . authority === file . authority ) {
105
+ if ( file . scheme === Schemes . file ) {
106
+ // On windows, we must use the native `path.resolve` to generate the relative path
107
+ // so that drive-letters are resolved cast insensitively. However we then want to
108
+ // convert back to a posix path to insert in to the document.
109
+ return encodeURI ( path . posix . normalize ( path . relative ( dir . fsPath , file . fsPath ) ) ) ;
110
+ }
111
+
112
+ return encodeURI ( path . posix . relative ( dir . path , file . path ) ) ;
113
+ }
114
+
115
+ return file . toString ( false ) ;
116
+ }
117
+
105
118
function getDocumentDir ( document : vscode . TextDocument ) : vscode . Uri | undefined {
106
119
const docUri = getParentDocumentUri ( document ) ;
107
120
if ( docUri . scheme === Schemes . untitled ) {
0 commit comments