From e96a220e1a8f7983633b2dd1ffa7d7667be8ec2b Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 7 Mar 2025 11:54:22 +0100 Subject: [PATCH] Meta page completion fix --- plug-api/lib/query_expression.ts | 3 +++ plugs/editor/complete.ts | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plug-api/lib/query_expression.ts b/plug-api/lib/query_expression.ts index b81b8fb9..f838d9a7 100644 --- a/plug-api/lib/query_expression.ts +++ b/plug-api/lib/query_expression.ts @@ -256,6 +256,9 @@ function evalSimpleExpression(type: string, val1: any, val2: any, val3: any) { throw new Error(`Invalid regexp: ${val2}`); } const r = new RegExp(val2[0], val2[1]); + if (Array.isArray(val1)) { + return val1.some((v) => r.test(v)); + } return r.test(val1); } case "!=~": { diff --git a/plugs/editor/complete.ts b/plugs/editor/complete.ts index dfb006fb..4aebbdf5 100644 --- a/plugs/editor/complete.ts +++ b/plugs/editor/complete.ts @@ -15,10 +15,10 @@ import { localDateString } from "$lib/dates.ts"; const isMetaPageFilter: QueryExpression = ["or", ["=", ["attr", "tags"], [ "string", "template", -]], ["=", [ +]], ["=~", [ "attr", "tags", -], ["string", "meta"]]]; +], ["regexp", "meta.+", ""]]]; // Completion export async function pageComplete(completeEvent: CompleteEvent) {