Repository navigation
fix(editor): cmd+arrow, up arrow, and gutter highlight at end of query - #1014
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three end-of-line/end-of-document bugs in the SQL editor, all rooted in
NSRange.containsbeing half-open and silently dropping theoffset == documentLengthcase.extendSelectionVisualLinelooked up the visual fragment withgetLine(atOffset:)(returns nil for an offset equal to the line length) and unconditionally subtracted the document's detected line-ending length even when the line itself had no trailing newline, capping the right bound one short. The fragment lookup now falls back tofragments.lastand the line-ending length is computed from the actual line text viaLineEnding(line:), matching the patternextendSelectionLinealready uses. Fixes Can't using cmd + arrow keys when on the last letter #1007.extendSelectionVertical's first/last line check usedlineStorage.first?.range.contains(offset). For a single-line query with the caret at offsetlengththat returns false, so it fell through to a geometry probe that found no line above and bailed. Now compares line IDs viatextLineForOffset(offset), which already returns the last line foroffset == length. Symmetric Down-on-last-line path is fixed too.drawLineNumbersmatched lines viaIndexSet.intersects(integersIn: lineRange)(half-open). Empty selections now route throughtextLineForOffset, mirroring howdrawSelectedLinesalready handles end-of-document carets.Test plan
swift testinLocalPackages/CodeEditTextView(76/76 passing) including the newVisualLineEndOfDocumentTests(6 cases, 5 of which failed before the fix) andCmdUpAtEndOfDocumentTests(5 cases, 1 failed before the fix)xcodebuild ... -only-testing:TableProTests/GutterHighlightTests(3 cases × arm64/x86_64) passesxcodebuild ... -scheme TablePro build) succeedsswiftlint --strictclean on every modified and added file