Fix evil-ghostel multi-line dd targeting the wrong line (#218)#222
Open
Fix evil-ghostel multi-line dd targeting the wrong line (#218)#222
Conversation
In multi-line TUI input (e.g. pi, ipython), ESC k dd deleted the last line instead of the line at point. Five changes: 1. Same-row dispatch for line-type evil-delete and evil-change. When point is on the same viewport row as the terminal cursor (single-line shell case), keep the readline-aware Ctrl-e/Ctrl-u shortcut — it clears the input area without us needing to know where the prompt ends. When point is on a different row (multi-line TUI case from #218), sync the terminal cursor to the deleted region's end and backspace through it. 2. After the same-row Ctrl-u path, snap point to the new terminal cursor position on the next redraw via a one-shot flag (evil-ghostel--sync-point-on-next-redraw). Otherwise point would be left at column 0 — on the prompt rather than at the start of the input area where the cursor lands. 3. evil-ghostel--cursor-to-point ignored scrollback when computing the buffer→viewport row diff, sending arrows off into space in any session with scrollback (i.e. essentially all of them). Mirror the math from evil-ghostel--reset-cursor-point. 4. evil-ghostel--delete-region sent (end - beg) backspaces blindly, counting box-padding spaces (written by TUIs with fixed-width input boxes) as input characters and eating far past the actual content. Strip per-line trailing whitespace before counting. Tradeoff documented: a line of pure user-typed indentation collapses to zero backspaces. 5. evil-replace's paste count now matches the delete count — both go through evil-ghostel--meaningful-length so trailing whitespace stripped from one side isn't re-added by the other. Verified live: shell `dd` / `cc` clears input via Ctrl-u with point landing at start of input area (after the prompt); pi `AAA\nBBB\nCCC` + ESC kk dd leaves `BBB` and `CCC` with `AAA` gone. Fixes #218
ff4f984 to
85b1bd4
Compare
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
Fixes #218 — in multi-line TUI input (pi, ipython, ptpython),
ESC k dddeleted the wrong line. Investigation surfaced four other latent bugs in the same code paths; bundled together since the user-visible fix doesn't work without them.dd/cc: keep the readline-aware Ctrl-e/Ctrl-u shortcut for the single-line shell case (where the buffer line includes the prompt prefix); use cursor-sync + backspaces only when point is on a different viewport row from the terminal cursor (the actual Evil multi-line issues in pi #218 case).evil-ghostel--cursor-to-point— previously off by exactly the scrollback line count.evil-replacecount consistency — paste and delete now both go throughevil-ghostel--meaningful-lengthso trailing whitespace stripped from one side isn't re-added by the other.Test plan
make test-evil— 56/56 pass, including 7 new tests covering each fix.dd/cc: input cleared via Ctrl-u, prompt preserved, point lands at start of input area.AAA\nBBB\nCCC+ ESCkk dd:AAAgone,BBBandCCCremain.