diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ca1d938..f0e9dbc 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -19,6 +19,7 @@ reverse. ## 2026-08-25 +- Fix: Ctrl+click on a dependency preceded by a non-breaking space did nothing, although the parser reads it as a dependency - Ctrl+click a dependency `:#id` in the text jumps to the line that defines the ID — Ctrl+Enter does the same at the caret ## 2026-08-24 diff --git a/frontend/src/autocomplete.js b/frontend/src/autocomplete.js index 3e3ca3d..df7069e 100644 --- a/frontend/src/autocomplete.js +++ b/frontend/src/autocomplete.js @@ -103,8 +103,11 @@ export function depIdAt(text, caret){ let m; while((m = DEP_TOKEN_G.exec(head))){ const p = m.index; - /* Alleinstehend angesetzt — `(:#a,#b)` bleibt damit Zitat (§1/D37). */ - if(p !== idEnd && p > 0 && !/[ \t]/.test(head[p - 1])) continue; + /* Alleinstehend angesetzt — `(:#a,#b)` bleibt damit Zitat (§1/D37). + `\s` wie im Parser, nicht nur Space/Tab: Auch vor einem geschützten + Leerzeichen (etwa aus einer Web-Seite kopiert) ist das Token eine + Abhängigkeit, und der Sprung muss dieselbe Zeile lesen wie der Parser. */ + if(p !== idEnd && p > 0 && !/\s/.test(head[p - 1])) continue; const end = p + m[0].length; if(col < p || col > end) continue; let s = p + 1; /* hinter dem `:` */ diff --git a/frontend/tests/deplink.test.js b/frontend/tests/deplink.test.js index b0b1262..601734b 100644 --- a/frontend/tests/deplink.test.js +++ b/frontend/tests/deplink.test.js @@ -58,6 +58,10 @@ describe('depIdAt — die ID unter der Schreibmarke (D67)', () => { expect(depIdAt(...at('- Front|end :#api'))).toBe(null); }); + it('geschütztes Leerzeichen vor dem Token zählt wie beim Parser als Leerraum', () => { + expect(depIdAt(...at('- X :#a|uth'))).toBe('auth'); + }); + it('in einer Fortsetzungszeile (D59) wird das Token erkannt', () => { expect(depIdAt(...at('- Langer Knoten \\\n :#a|pi'))).toBe('api'); });