Skip to content

Let evil-ghostel move left when typed text is marked as prompt - #794

Merged
dakra merged 1 commit into
mainfrom
fix/evil-ghostel-unmarked-input-clamp
Nov 6, 2026
Merged

dakra merged 1 commit into
mainfrom
fix/evil-ghostel-unmarked-input-clamp

Conversation

@dakra

@dakra dakra commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Problem

0557ea77 clamps a leftward same-row target in evil-ghostel-goto-input-position to ghostel--cursor-row-input-start. That is only valid where the shell marks its input start.

fish before 4.3 sends OSC 133 A without B. The terminal then keeps marking typed text as prompt, the ghostel-prompt run ends at the cursor on every row with typed text, and the "input start" is the cursor itself. Every leftward move was clamped away: with echo abcd typed, ESC h i X gave echo abcdX instead of echo abXcd, and h h x deleted the wrong character. The insert-state entry from copy mode had the same clamp.

The clamp is not in a release yet (it landed after 0.61.0).

Fix

evil-ghostel--cursor-left-limit replaces the direct calls at both sites. A prompt that ends exactly at the cursor counts as the input start only when ghostel-prompt-regexp ends there too:

No state and no core change. The insert-state entry also gains the "regexp match ends past the cursor" guard the command already had.

Known limitation

On an empty input, the #788 clamp now needs the regexp to match the prompt to its end. Where it does not, 0 i behaves as in 0.61.0 again (left arrows the shell ignores, caret in the prompt until the next keystroke). Examples:

  • a prompt whose first prompt character is not its last, e.g. oh-my-zsh robbyrussell: ➜ ghostel git:(main) ✗
  • more than 60 characters before the prompt character, or no prompt character
  • ghostel-prompt-regexp set to nil

With typed input the clamp is unaffected on shells that send B. An empty OSC 133 prompt and prompt-marked typed text look identical in the buffer, so closing this gap needs to know whether B arrived since the last A (a flag set in ghostel--osc133-marker, or a native query of the cursor's semantic state).

Testing

  • make -j8 test test-native test-evil test-consult lint: 1518 tests, 0 unexpected, lint clean. test-zig and the module build were not run locally (Homebrew has Zig 0.17.1, build.zig requires 0.17.0); the change is elisp only and the tests ran against a module built from the same Zig sources.
  • New ERT tests: leftward move and copy-mode insert entry over prompt-marked typed text (both fail on main), and the empty OSC 133 prompt clamp.
  • elate, fish with --features no-mark-prompt (A without B): a leftward-move scenario (h i, h h x, h h a, b d w, b c w) goes from 3 failures on main to 0. shells.json goes from 19 failing groups to 16; 0 i, 0 a and 0 i wrap pass again, no group fails only with the change. The remaining 16 need ^ / I to find the input start on such a shell and fail before 0557ea77 too.
  • elate, regular shells: shells.json on bash, zsh, fish 4.9 and nu, python3.json, readonly-evil-ghostel.json (including the empty-prompt clamp group), tracking-ghostel.json and the four boundary-* suites all pass apart from the documented xfails.

fish before 4.3 sends OSC 133 A without B, so the terminal keeps marking
typed text as prompt and ghostel--cursor-row-input-start returns the
cursor on every row with typed text.  evil-ghostel-goto-input-position
and the insert-state entry clamped a leftward target to that position:
i, a and x left of the cursor acted at the cursor instead.

Take the limit from evil-ghostel--cursor-left-limit, which counts a
prompt ending at the cursor only when ghostel-prompt-regexp ends there
too.  On an empty input whose prompt the regexp does not match to its
end, i and a from inside the prompt send their left arrows again.

The insert-state entry also ignores a regexp match that ends past the
cursor, as evil-ghostel-goto-input-position does.
@dakra
dakra force-pushed the fix/evil-ghostel-unmarked-input-clamp branch from 695d2eb to 5048d0f Compare November 6, 2026 21:11
@dakra
dakra merged commit 5048d0f into main Nov 6, 2026
27 checks passed
@dakra
dakra deleted the fix/evil-ghostel-unmarked-input-clamp branch November 6, 2026 21:12

This branch was previously deployed

1 inactive deployment
github-pages — 5048d0f8 Deployed Nov 6, 2026 by dakra via deploy #251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant