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

Vim mode: delete subword deleting beyond the first punctuation #23344

Open
1 task done
sasanquaa opened this issue Jan 19, 2025 · 3 comments
Open
1 task done

Vim mode: delete subword deleting beyond the first punctuation #23344

sasanquaa opened this issue Jan 19, 2025 · 3 comments
Labels

Comments

@sasanquaa
Copy link

sasanquaa commented Jan 19, 2025

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

  • Subword was implemented in vim: Add Subword Textobject #22387 (thanks!)

  • Use "w": "vim::NextSubwordStart" in keymap.json

  • Inside the below text with <char> indicating the cursor:

"ctrl-w h": ["workspace::ActivatePaneIn<D>irection", "Left"],
"ctrl-w l": ["workspace::ActivatePaneInDirection", "Right"]
  • Use vim dw and text becomes:
"ctrl-w h": ["workspace::ActivatePaneIn<">,Left"],
"ctrl-w l": ["workspace::ActivatePaneInDirection", "Right"]

Or when cursor at:

"ctrl-w h": ["workspace::ActivatePaneInDirection", "<L>eft"],
"ctrl-w l": ["workspace::ActivatePaneInDirection", "Right"]
  • Use vim dw and text becomes (delete beyond " and two lines joined):
"ctrl-w h": ["workspace::ActivatePaneInDirection", "<">ctrl-w l": ["workspace::ActivatePaneInDirection", "Right"]

In both cases, I expect the delete to stop at "

Zed Version and System Specs

Zed: v0.171.0 (Zed Dev b472bd9)
OS: Windows 10.0.19044
Memory: 31.8 GiB
Architecture: x86_64
GPU: NVIDIA GeForce RTX 3060 || NVIDIA || 546.17

If applicable, add screenshots or screencasts of the incorrect state / behavior

No response

If applicable, attach your Zed.log file to this issue.

No response

@sasanquaa sasanquaa added admin read bug [core label] labels Jan 19, 2025
@0x2CA
Copy link
Contributor

0x2CA commented Jan 20, 2025

The meaning of dw is to delete to the next word start, not to delete the word.

dw vim::NextSubwordStart

diw vim::Subword

This is a motions issue.

vim: subword motions #8725

@sasanquaa
Copy link
Author

Please correct me if I am wrong, but with the default word motion w: vim::NextWordStart, using dw would stop at " in the above example. So I am having the same expectation for dw with w: vim::NextSubwordStart.

@thomasheartman
Copy link
Contributor

I found the same issue (I think) and didn't research the current list of issues well enough before posting it (linked it as a duplicate now). In case it helps clarify the problem, here's the issue description from my duplicate:

Summary

NextWordStart and NextSubwordStart appear to treat punctuation differently. NextWordStart stops at punctuation, NextSubwordStart ignores punctuation and goes to the next word after a space

Steps to trigger the problem:

  1. In a new file, with vim mode active, enter the text "word, next"
  2. In normal mode, with your cursor somewhere in "word", visually select or delete with NextWordStart and NextSubwordStart
  3. Notice the behavior is different

Actual Behavior:
From this starting point:

Image

delete NextWordStart (does as I expect and deletes up until the comma)

Image

delete NextSubwordStart (deletes past the comma up until the next word separated by whitespace)

Image

Expected Behavior:

They should behave the same in this case (I'd expect the NextWordStart behavior).

My context stack tells me that they're using equivalent commands (the vim operator in the context is incorrect as it changes when I set up the screenshot command; it should be d):

Word:

Image

Subword
Image

Zed Version and System Specs

Zed: v0.174.6 (Zed)
OS: macOS 14.6.1
Memory: 16 GiB
Architecture: aarch64

@devzeth devzeth removed the bug [core label] label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants