tui: fix cursor desync by scanning rendered buffer
Instead of simulating ratatui's word wrapping algorithm, scan the rendered buffer to find the actual cursor position. This correctly handles word wrapping, unicode widths, and any other rendering nuances that ratatui applies. The old code computed wrapped_height() and cursor position based on simple character counting, which diverged from ratatui's WordWrapper that respects word boundaries. Now we render first, then walk the buffer counting visible characters until we reach self.cursor. This is O(area) but the input area is small (typically < 200 cells), so it's negligible.
This commit is contained in:
parent
5308c8e3a4
commit
ec79d60fbd
4 changed files with 52 additions and 133 deletions
|
|
@ -32,3 +32,4 @@ figment = { version = "0.10", features = ["env"] }
|
|||
json5 = "0.4"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
tui-markdown = "0.3"
|
||||
unicode-width = "0.2.2"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue