Skip to content

Build your personal knowledge base with Trilium Notes

client/snippets: ignore archived snippets

Adorian Doran511cdaca6dc9
diff --git a/apps/client/src/widgets/type_widgets/code/snippets.ts b/apps/client/src/widgets/type_widgets/code/snippets.ts
index b89d543ce0..524213e21a 100644
--- a/apps/client/src/widgets/type_widgets/code/snippets.ts
+++ b/apps/client/src/widgets/type_widgets/code/snippets.ts
@@ -25,7 +25,8 @@ export interface CodeSnippet {
* Markdown editor, or a MIME comparison for a code editor).
*/
export async function getCodeSnippets(matches: (note: FNote) => boolean): Promise<CodeSnippet[]> {
- const notes = (await search.searchForNotes("#snippet")).filter(matches);
+ // The `search` route includes archived notes, so drop archived snippets explicitly.
+ const notes = (await search.searchForNotes("#snippet")).filter((note) => matches(note) && !note.isArchived);
return Promise.all(notes.map(async (note) => ({
noteId: note.noteId,
diff --git a/apps/client/src/widgets/type_widgets/text/snippets.ts b/apps/client/src/widgets/type_widgets/text/snippets.ts
index 4c9884d70d..b2baa9b10e 100644
--- a/apps/client/src/widgets/type_widgets/text/snippets.ts
+++ b/apps/client/src/widgets/type_widgets/text/snippets.ts
@@ -28,7 +28,7 @@ export default async function getTemplates() {
// starting with "(" trips the search lexer (the leading paren is dropped, see lex.ts), which
// corrupts the parse and matches every note.
const snippets = (await search.searchForNotes("#textSnippet OR #snippet"))
- .filter((snippet) => snippet.type === "text");
+ .filter((snippet) => snippet.type === "text" && !snippet.isArchived);
const definitions: TemplateDefinition[] = [];
for (const snippet of snippets) {
const { description } = await invalidateCacheFor(snippet);