From e9933a16eea708ad21a20851d222ef652e7b6a1a Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 27 Nov 2024 13:34:56 -0800 Subject: [PATCH] improv: comment diff snippet --- core/autocomplete/templating/formatting.ts | 23 ++++------------------ 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/core/autocomplete/templating/formatting.ts b/core/autocomplete/templating/formatting.ts index be7fe7a150..bdbe56c50f 100644 --- a/core/autocomplete/templating/formatting.ts +++ b/core/autocomplete/templating/formatting.ts @@ -13,12 +13,14 @@ const getCommentMark = (helper: HelperVars) => { }; const addCommentMarks = (text: string, helper: HelperVars) => { + const commentMark = getCommentMark(helper); const lines = [ ...text .trim() .split("\n") - .map((line) => `${getCommentMark(helper)} ${line}`), + .map((line) => `${commentMark} ${line}`), ]; + return lines.join("\n"); }; @@ -61,11 +63,6 @@ const commentifySnippet = ( }; }; -const SNIPPET_TYPES_TO_COMMENT = [ - AutocompleteSnippetType.Code, - AutocompleteSnippetType.Clipboard, -]; - export const formatSnippets = ( helper: HelperVars, snippets: AutocompleteSnippet[], @@ -88,19 +85,7 @@ export const formatSnippets = ( } }) .map((item) => { - if (SNIPPET_TYPES_TO_COMMENT.includes(item.type)) { - return commentifySnippet(helper, item); - } - - return item; - }) - .map((item) => { - if (SNIPPET_TYPES_TO_COMMENT.includes(item.type)) { - const commentMark = getCommentMark(helper); - return item.content + `\n${commentMark}\n${commentMark}`; - } - - return item.content; + return commentifySnippet(helper, item).content; }) .join("\n") + `\n${currentFilepathComment}` );