Skip to content

feat: SQL syntax highlighting for iOS query editor#621

Merged
datlechin merged 1 commit intomainfrom
feat/ios-syntax-highlighting
Apr 7, 2026
Merged

feat: SQL syntax highlighting for iOS query editor#621
datlechin merged 1 commit intomainfrom
feat/ios-syntax-highlighting

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

  • SQL syntax highlighting in the iOS query editor via UITextView + NSTextStorageDelegate
  • Colors: keywords (blue), strings (red), numbers (orange), comments (gray), functions (purple)
  • Incremental highlighting on each keystroke (line-boundary expansion, not full rescan)
  • 10K character cap for performance
  • Protected ranges: keywords inside strings/comments are not colored
  • Dark mode compatible (UIColor semantic colors)

Architecture

  • SQLSyntaxHighlighter: stateless enum with pre-compiled regex patterns
  • SQLHighlightTextView: UIViewRepresentable wrapping UITextView
  • NSTextStorageDelegate fires on character edits with exact edited range
  • beginEditing/endEditing for batched attribute changes

Test plan

  • Type SELECT * FROM users WHERE id = 1 - keywords blue, number orange
  • Type 'hello world' - string red
  • Type -- comment - gray
  • Type /* block */ - gray
  • 'SELECT' inside string stays red (not blue)
  • Paste large SQL (>10K) - no freeze
  • Dark mode - colors adapt
  • Cursor, undo, copy/paste all work

@datlechin datlechin force-pushed the feat/ios-syntax-highlighting branch from 0321a4f to 64ae8c3 Compare April 7, 2026 12:37
@datlechin datlechin merged commit 8d3e164 into main Apr 7, 2026
3 checks passed
@datlechin datlechin deleted the feat/ios-syntax-highlighting branch April 7, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant