Highlight strings and comments that span line breaks #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/multiline-string-highlighting"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The highlighter tokenized each line on its own. After a line break inside a
'...'string, the rest of the string was colored as SQL code. Multi-line"..."quoted identifiers and/* ... */block comments broke the same way.Fix
sql_highlight.rs: newLexState(Normal,SingleQuote,DoubleQuote,BlockComment).tokenize_sql_line_from(line, state)continues a run carried over from the previous line and returns the state at the end of the line.tokenize_sql_lineis kept as theNormal-start wrapper.line_start_states(lines)computes each line's start state with a byte scan of quotes and comments only. It builds no tokens, and it sharesskip_quoted/skip_block_commentwith the tokenizer so the two can't drift apart. Scanning bytes is exact because the relevant characters are ASCII, and UTF-8 never uses those byte values inside multi-byte characters.vim_editor.rs:layout_sql_linetakes the start state. States are computed before mouse hit-testing and again after keyboard input, and only down to a full screen past the scroll position or cursor.AGENTS.md.Testing
cargo testpasses (28 tests), including 5 new highlighter tests: a string across lines,''escapes across lines, block comments and quoted identifiers across lines, quotes inside--comments, and agreement betweenline_start_statesand the tokenizer.🤖 Generated with Claude Code