fix(tui): 上下键在折行/历史项内应移动光标而非误翻历史#192
Merged
Merged
Conversation
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.
问题
上下方向键在两种场景下会"误触发历史翻阅",导致无法在长内容里用键盘移动光标:
修复
与 ↑ / ↓ 对称处理光标位置:
Line()==0且 虚拟行偏移LineInfo().RowOffset==0)时才翻阅历史,折行内交给 textarea 上移光标。否则下移光标,与 ↑ 行为一致。
原有行为保持不变:输入框真顶端按 ↑ 仍翻阅历史,历史项最末行按 ↓ 仍翻下一条。
验证
新增 4 个回归测试(
tui/up_wrap_test.go+tui/down_history_nav_test.go):TestUpArrowOnWrappedLineBug— 长行 wrap 内 ↑ 不误翻历史TestUpArrowAtTrueTopNavigatesHistory— 真顶端 ↑ 仍翻历史TestDownArrowInsideMultilineHistoryMovesCursor— 历史项中间行 ↓ 下移光标TestDownArrowAtHistoryBottomNavigates— 历史项底部 ↓ 仍翻下一条go test ./tui/全部通过。