rustyline
rustyline copied to clipboard
Keep track of layout of input buffer spans
Builds on top of https://github.com/gwenn/rustyline/pull/2/files
When moving cursor up or down a line, it should not change columns. To be precise, it should not change columns on the screen.
Current implementation was making sure it was not changing number of graphemes from the beginning of the line. This works correctly, as long as prompt is empty. If it so not empty, the cursor moves up and down like this:
> c_mmand \
argument1
> command \
a_gument1
This PR changes this behavior to this:
> c_mmand \
argument1
> command \
arg_ment1
This change is also needed for continuation prompts.
To make this happen, I had to:
- keep track of layout of input buffer spans (one for each line in the input buffer),
- refactor
Renderer::compute_layout
intoLayout::compute
, - change
LineBuffer::move_to_line
to takeLayout
as a parameter, - fix
State::move_cursor
.