This commit is contained in:
th committed 2026-04-07 22:02:17 +02:00
1 parent 719f9d51ff
commit 6855381d5c
1 file changed
+8 -5
+8 -5
View File
@@ -465,11 +465,14 @@ body.addEventListener('input', () => {
function getTagQuery() {
const before = body.value.substring(0, body.selectionStart);
// Find # preceded by whitespace or start of line, not part of heading (# + space)
const m = before.match(/(?:^|[\s])#([a-zA-Z0-9_\/-]*)$/m);
if (!m) return null;
const start = before.length - m[0].length + (m[0].startsWith('#') ? 0 : 1); // skip leading whitespace
return { start, query: m[1] };
const idx = before.lastIndexOf('#');
if (idx < 0) return null;
// Must be at start or after whitespace
if (idx > 0 && !/\s/.test(before[idx - 1])) return null;
// Everything after # to cursor must be valid tag chars (or empty)
const query = before.substring(idx + 1);
if (query && /[^a-zA-Z0-9_\/-]/.test(query)) return null;
return { start: idx, query };
}
function getAllTags() {