-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Off-by-one error for df, dt, dF, dT motions with vi key bindings #5770
Comments
Should fix fish-shell#5770. Fixes an off-by-one error with df, dt, dF, and dT strokes. Too little was deleted in fish as opposed to vi.
This is a more general problem because emacs' and vi's idea on where the cursor is differs. Adding "forward-char" and "backward-char" to bindings doesn't really work because they'd also be executed if the command fails (e.g. do "dfG" on a line that doesn't have a "G"). At the very least it would have to be "forward-jump and backward-char" (and forward-jump would have to be adjusted to set the bind status). (Yes, that is indeed just "and" without a semicolon - this isn't fish-script, it's the DSL for bind functions, which is a bit weird) |
Have you guys considered using neovim as a backend to drive the shell prompt? Is the plugin API robust enough to facilitate that? That's something I would be interested in working on- a plugin for fish that uses neovim as a backend to get proper vi bindings. EDIT: Just for reference, that approach is first-class in Oni and an optional feature in VSCode's vim plugin. |
It's been thrown around idly. I can't say I'm a fan of the dependency, and I'm not sure if it would actually work well, but if someone implemented it and it's well-done we might merge it. |
I looked into it a few times myself, but the last time that I sat down to do it I was put off by the assumptions neovim makes about the purposes behind the integration. The RPC api is (was?) very restrictive in terms of how an integration must be approached and the kind of state that would be kept client-side, so I ended up tabling my efforts. |
This off-by-one inconsistency also applies to selecting text in visual mode: in vim, the selection includes the character under the cursor. In fish, the selection includes up to but not including the character under the cursor. |
The current cursor position should be included in the selection to be consistent with the behavior of vi. Fixes #5770
In vi,
df
anddF
are inclusive (in that they delete the character the motion is targetting) anddt
anddT
are exclusive. Right now, in fish, all of these commands delete one character less than they do in vi.To reproduce:
fish_vi_key_bindings
)df
,dF
,dt
, ordT
and observe how it differs from vifish, version 3.0.2
Linux josbox 4.20.15-1-MANJARO #1 SMP PREEMPT Sun Mar 10 08:50:44 UTC 2019 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: