Skip to content

fix: horizontal scroll, Home/End keys, and line operations in SQL editor#500

Merged
datlechin merged 1 commit intomainfrom
fix/horizontal-scroll
Mar 29, 2026
Merged

fix: horizontal scroll, Home/End keys, and line operations in SQL editor#500
datlechin merged 1 commit intomainfrom
fix/horizontal-scroll

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

  • Fix horizontal scrolling for long lines (upstream bug in CodeEditTextView)
  • Add Home/End key support with all modifier combinations (bug: Home and End keys don't work in the SQL editor #448)
  • Add duplicate line (Cmd+Shift+D), delete line (Cmd+Shift+K), move line up/down (Option+Up/Down)
  • Fix move line up/down for last-line and emoji content edge cases

Root Causes

Horizontal scroll: Variable shadowing bug in CodeEditTextView layoutLine()var maxFoundLineWidth = maxFoundLineWidth shadowed the inout param, so maxLineWidth never updated. Also patched styleTextView() to respect wrapLines.

Home/End: AppKit maps Home/End to scrollToBeginningOfDocument:/scrollToEndOfDocument: which only scroll without moving cursor. CodeEditTextView didn't override these.

Line operations: moveLinesUp()/moveLinesDown() existed but were never wired to key bindings. Also had bugs with trailing-newline handling and UTF-16 string splitting.

Changes

  • CodeEditTextView (vendored): fix maxFoundLineWidth shadowing, add Home/End handling in keyDown, add moveToBeginningOfLine/moveToEndOfLine/centerSelectionInVisibleArea overrides
  • CodeEditSourceEditor: patch styleTextView()/styleScrollView() for horizontal scroll, wire Cmd+Shift+D/K and Option+Up/Down in handleCommand, add duplicateLine()/deleteLine(), rewrite moveLinesUp()/moveLinesDown() with correct newline and UTF-16 handling
  • SQLEditorCoordinator: remove fragile horizontal scroll workaround, fix redundant double dispatch in settings observer

Test plan

  • Type long line with word wrap off — horizontal scroll works
  • Home/End moves to start/end of line
  • Cmd+Home/End moves to start/end of document
  • Shift variants extend selection
  • Cmd+Shift+D duplicates current line
  • Cmd+Shift+K deletes current line
  • Option+Up/Down moves line up/down
  • Move line works correctly on last line (no trailing newline)
  • Undo works after all line operations

@datlechin datlechin force-pushed the fix/horizontal-scroll branch from 4500f35 to b4e7fce Compare March 29, 2026 13:13
@datlechin datlechin merged commit f5afbe2 into main Mar 29, 2026
1 check passed
@datlechin datlechin deleted the fix/horizontal-scroll branch March 29, 2026 13:15
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