fix: move caret to previous line on arrow-up inside code blocks - #8978
Open
BetterAndBetterII wants to merge 1 commit into
Open
BetterAndBetterII wants to merge 1 commit into
BetterAndBetterII wants to merge 1 commit into
Conversation
Geometry-based vertical movement includes the language-picker header, so Up jumped to the previous block instead of the previous line. Register a newline-based arrow-up handler before arrowUpToTitle. Fixes AppFlowy-IO#8936
Contributor
Reviewer's GuideIntroduces a prioritized, newline-based Up-arrow handler for code blocks, keeping the caret within the block on lines after the first while preserving existing fallback behavior at the first line and in other contexts. Sequence diagram for code block Arrow-Up handlingsequenceDiagram
participant User
participant Shortcuts as Command shortcuts
participant Handler as arrowUpInCodeBlock
participant Editor as EditorState
participant Default as Default arrow-up handler
User->>Shortcuts: Arrow Up
Shortcuts->>Handler: _arrowUpInCodeBlockHandler(editorState)
Handler->>Editor: getNodeAtPath(selection.end.path)
alt Collapsed caret in a code block after the first line
Handler->>Editor: selection = Selection.collapsed(previous line offset)
Handler-->>User: KeyEventResult.handled
else First line or non-code-block context
Handler-->>Shortcuts: KeyEventResult.ignored
Shortcuts->>Default: Handle Arrow Up
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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
arrowUpInCodeBlockhandler beforearrowUpToTitleso Up moves to the previous line (same column, clamped) while the first line still falls through to the default handler.Fixes #8936
Test plan
flutter test test/unit_test/document/shortcuts/code_block_arrow_command_test.dart(7 cases)Summary by Sourcery
Fix Up-arrow navigation in multi-line code blocks so the caret moves between code lines without skipping to the previous block.
Bug Fixes:
Tests: