Skip to content
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

Bug report: vim search mode would leak delete key #976

Closed
LumenYoung opened this issue Jul 24, 2024 · 9 comments · Fixed by #1145
Closed

Bug report: vim search mode would leak delete key #976

LumenYoung opened this issue Jul 24, 2024 · 9 comments · Fixed by #1145

Comments

@LumenYoung
Copy link

As suggested in the title, I find this potential bug, and it is easy to reproduce on my side

  1. enable vim mode
  2. type / to enter search mode
  3. enter random characters and then backspace to simulate a deletion

Expected behavior: the character in search should be delete

Current behavior: the searched content is not deleted, rather the character under the cursor is deleted.

SB Version: 0.8.1

@erinsummer
Copy link

erinsummer commented Aug 8, 2024

I'm able to reproduce this in 0.9.0 as well.

I'm seeing the issue any time the cursor is supposed to be focused in the vim command line. I thought perhaps it was related to one of my (many) browser extensions, but after disabling them all the input focus shift persists.

Specifics:

  • SB: 0.9.0
  • Debian GNU/Linux 11 (bullseye) 5.10.221-1
  • via SSL/nginx (no proxy)
  1. enable vim mode
  2. use a vim motion (select some text, start a search, anything to open the command editor). I was trying to do a find/replace using :s%, and kept making typing errors. Arrow keys, backspace, and maybe some other keys seem to be sent back to the editor rather than the vim command line
  3. Escaping out of the vim command leaves one with whatever changes were made by the keystrokes being passed through to their document instead of their vim command prompt

Expected: send the keystrokes to the (focused) vim command prompt rather than the main editor itself

@meain
Copy link
Contributor

meain commented Aug 9, 2024

Probably related. I've had cases where when I press G to go to the last line in normal mode, it would just enter that into the editor.

@lutzky
Copy link
Contributor

lutzky commented Nov 9, 2024

Silverbullet is based on codemirror, but this demo doesn't have this bug: https://codemirror.net/5/demo/vim.html. That demo is for an older version though.

lutzky added a commit to lutzky/silverbullet that referenced this issue Nov 9, 2024
The standard keymap conflicts with the vim mode, e.g. not allowing arrow
keys to move through the vim commandline for `/` and `:` commands. The
keys described in
https://codemirror.net/docs/ref/#commands.standardKeymap seem to work
just fine without it in vim mode.

Fixes silverbulletmd#976
zefhemel pushed a commit that referenced this issue Nov 11, 2024
The standard keymap conflicts with the vim mode, e.g. not allowing arrow
keys to move through the vim commandline for `/` and `:` commands. The
keys described in
https://codemirror.net/docs/ref/#commands.standardKeymap seem to work
just fine without it in vim mode.

Fixes #976
@lutzky
Copy link
Contributor

lutzky commented Nov 11, 2024

This broke the Enter key in insert mode for ordinary paragraphs. Workaround: Go back to command mode and hit o.

I think this is caused by replit/codemirror-vim#182.

@LumenYoung
Copy link
Author

Thanks a lot @lutzky for the long waited fix! I've tested the latest commit and it works on my instance.

But one thing I still find not really reasonable for a long term vim user is the del key in the normal mode still deletes in the original text instead of just moving backward. I think it is pretty annoying and not intended for vim usage.

Do you see a way to make this behavior consistent with vim's behavior? Technically it doesn't belongs to this bug but I would assume these are relevant and could be fixed with similar manner.

@lutzky
Copy link
Contributor

lutzky commented Nov 11, 2024

@LumenYoung interesting, I hadn't noticed that. This cannot be fixed in the same manner as it reproduces in the codemirror-vim demos (v5, v6). Interestingly, I don't see this posted on https://github.com/replit/codemirror-vim/issues?q=is%3Aissue+delete.

@LumenYoung
Copy link
Author

@LumenYoung interesting, I hadn't noticed that. This cannot be fixed in the same manner as it reproduces in the codemirror-vim demos (v5, v6). Interestingly, I don't see this posted on https://github.com/replit/codemirror-vim/issues?q=is%3Aissue+delete.

Ah, thanks for the knowledge. Emm, this is pretty annoying and I will file a report to the codemirror team. I think these kind of problem really gives me a sense of unstability when writing on the silverbullet but with your patch it is already getting better. Thanks!

@LumenYoung
Copy link
Author

@LumenYoung interesting, I hadn't noticed that. This cannot be fixed in the same manner as it reproduces in the codemirror-vim demos (v5, v6). Interestingly, I don't see this posted on https://github.com/replit/codemirror-vim/issues?q=is%3Aissue+delete.

Hey @lutzky, I've tried the v6 demo here https://raw.githack.com/replit/codemirror-vim/master/dev/web-demo.html and I can't reproduce this problem. Can you verify again that you can delete the character in normal mode when hovering above them and hit del key? I think the vim mode on both v5 and v6 demo are behaving correctly.

@lutzky
Copy link
Contributor

lutzky commented Nov 12, 2024

Loading the page, and hitting (in Command mode) Down-Down-Right-Right-Del indeed deletes the (p) character at that location.

image

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 a pull request may close this issue.

4 participants