Skip to content

Commit 882cdc0

Browse files
authored
Use newlines to separate inserted images (microsoft#164632)
Fixes microsoft#164610
1 parent 21431fc commit 882cdc0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

extensions/markdown-language-features/src/commands/insertResource.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function createInsertLinkEdit(activeEditor: vscode.TextEditor, selectedFiles: vs
8484
insertAsImage: insertAsImage,
8585
placeholderText: selectionText,
8686
placeholderStartIndex: (i + 1) * selectedFiles.length,
87+
separator: insertAsImage ? '\n' : ' ',
8788
});
8889

8990
return snippet ? new vscode.SnippetTextEdit(selection, snippet) : undefined;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ interface UriListSnippetOptions {
6767
* If `undefined`, tries to infer this from the uri.
6868
*/
6969
readonly insertAsImage?: boolean;
70+
71+
readonly separator?: string;
7072
}
7173

7274
export function createUriListSnippet(document: vscode.TextDocument, uris: readonly vscode.Uri[], options?: UriListSnippetOptions): vscode.SnippetString | undefined {
@@ -93,8 +95,8 @@ export function createUriListSnippet(document: vscode.TextDocument, uris: readon
9395

9496
snippet.appendText(`](${mdPath})`);
9597

96-
if (i <= uris.length - 1 && uris.length > 1) {
97-
snippet.appendText(' ');
98+
if (i < uris.length - 1 && uris.length > 1) {
99+
snippet.appendText(options?.separator ?? ' ');
98100
}
99101
});
100102
return snippet;

0 commit comments

Comments
 (0)