diff --git a/integrations/logseq-native-modes/README.md b/integrations/logseq-native-modes/README.md index 73a9365..05048d1 100644 --- a/integrations/logseq-native-modes/README.md +++ b/integrations/logseq-native-modes/README.md @@ -36,3 +36,32 @@ EJS, ERB, ASP.NET and JSP use the default CodeMirror 5 scriptlet delimiters. The Elixir tokenizer covers source highlighting, including interpolation and sigils. It does not parse the contents of regular expressions or embedded templates. + +## Scheme and Common Lisp bracket matching + +Logseq enables structural bracket highlighting for Clojure and EDN. The legacy +Scheme and Common Lisp modes provide syntax highlighting, but their token +types cannot reliably identify structural delimiters. With the generic bracket +matcher enabled and the caret just after the opening parenthesis, these inputs +produce the following matches (zero-based UTF-16 offsets). + +| Mode | Input | Expected closing offset | Actual closing offset | +| --- | --- | --- | --- | +| Scheme | `'(")")` | 5 | 3 (inside the string) | +| Scheme | `(#\))` | 4 | 3 (character literal) | +| Common Lisp | `(\))` | 3 | 2 (escaped symbol) | + +The [Scheme tokenizer](legacy-modes/mode/scheme.ml) uses the same `atom` style +for quoted list delimiters and their contents. It also does not consume the +delimiter glyph in a `#\)` character literal as part of the literal. The +[Common Lisp tokenizer](legacy-modes/mode/commonlisp.ml) consumes the backslash +before classifying the next character, so an escaped `)` gets the same +`bracket` style as a list closer. + +The [generic matcher](../../packages/language/bracket_matching.ml) compares +syntax node types when scanning raw characters without delimiter metadata. +The native catalog and upstream CodeMirror Legacy Modes 6.5.5 with Language +6.13.1 reproduce these results. Disabling token merging in upstream +`StreamLanguage` leaves the results unchanged. Reliable matching requires +reader-aware recognition of literals and escapes, plus a way for the matcher +to use only explicitly identified structural delimiters.