Use newlines to separate inserted images (#164632)

Fixes #164610
This commit is contained in:
Matt Bierner 2022-10-25 12:21:36 -07:00 committed by GitHub
parent 21431fce38
commit 882cdc0a17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -84,6 +84,7 @@ function createInsertLinkEdit(activeEditor: vscode.TextEditor, selectedFiles: vs
insertAsImage: insertAsImage,
placeholderText: selectionText,
placeholderStartIndex: (i + 1) * selectedFiles.length,
separator: insertAsImage ? '\n' : ' ',
});
return snippet ? new vscode.SnippetTextEdit(selection, snippet) : undefined;

View file

@ -67,6 +67,8 @@ interface UriListSnippetOptions {
* If `undefined`, tries to infer this from the uri.
*/
readonly insertAsImage?: boolean;
readonly separator?: string;
}
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
snippet.appendText(`](${mdPath})`);
if (i <= uris.length - 1 && uris.length > 1) {
snippet.appendText(' ');
if (i < uris.length - 1 && uris.length > 1) {
snippet.appendText(options?.separator ?? ' ');
}
});
return snippet;