zed icon indicating copy to clipboard operation
zed copied to clipboard

vim: Show 'j' from jk pre-emptively

Open ConradIrwin opened this issue 6 months ago • 2 comments

Fixes: #29812 Fixes: #22538

Co-Authored-By: [email protected]

Release Notes:

  • vim: Multi-key bindings in insert mode will now show the pending keystroke in the buffer. For example if you have jk mapped to escape, pressing j will immediately show a j.

ConradIrwin avatar Jun 03 '25 18:06 ConradIrwin

will this also close https://github.com/zed-industries/zed/issues/22538?

niekdomi avatar Jun 03 '25 21:06 niekdomi

I think so, yes!

cc @little-dude for testing

ConradIrwin avatar Jun 03 '25 21:06 ConradIrwin

Hey, @ConradIrwin

I just tested this feature and although this works totally fine, the behavior looks a bit buggy

https://github.com/user-attachments/assets/bdf17b9c-7588-417a-9b36-c6e85f7341ae

As you can see in the clip, the cursor is placed before the j. It looks like the delayed key is inserted without "updating" the cursor position

ghost avatar Jun 06 '25 23:06 ghost

Hah, funnily I changed it to match vim - we could do it the other way too though

ConradIrwin avatar Jun 07 '25 02:06 ConradIrwin

in neovim is use better-escape.nvim which has exactly this behavior and imo it feels more "natural".

https://github.com/user-attachments/assets/a556a090-3907-475d-b4be-7d13fa0d0359

ghost avatar Jun 07 '25 08:06 ghost

Hah, funnily I changed it to match vim - we could do it the other way too though

I'd agree with @domokopter. The behavior looks quite janky. Even if it does match how Vim behaves. j isn't too common a letter, but I still think it's better to make things look less janky when possible.

j_doesnt_move_cursor_ahead.webm

omniwrench avatar Jul 23 '25 14:07 omniwrench

:+1: I'd happily merge a PR that makes it more zed-like if you want to give it a go.

ConradIrwin avatar Jul 24 '25 05:07 ConradIrwin

I'll give it a shot. Could you let me know the section of the code base related to this? The same files changed in this PR?

omniwrench avatar Jul 24 '25 09:07 omniwrench

Should just be in the observe_pending_keystrokes function added in this PR. You can see it does some edits and moves the cursor, it probably needs to do the opposite of what it does now.

ConradIrwin avatar Jul 24 '25 14:07 ConradIrwin