Skip to content

Commit

Permalink
Merge pull request #3111 from continuedev/tomasz/comment-diff-snippet
Browse files Browse the repository at this point in the history
Comment out diff snippet
  • Loading branch information
tomasz-stefaniak authored Nov 28, 2024
2 parents 8f2edef + e9933a1 commit 2138122
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions core/autocomplete/templating/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
};

Expand Down Expand Up @@ -61,11 +63,6 @@ const commentifySnippet = (
};
};

const SNIPPET_TYPES_TO_COMMENT = [
AutocompleteSnippetType.Code,
AutocompleteSnippetType.Clipboard,
];

export const formatSnippets = (
helper: HelperVars,
snippets: AutocompleteSnippet[],
Expand All @@ -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}`
);
Expand Down

0 comments on commit 2138122

Please sign in to comment.