zed icon indicating copy to clipboard operation
zed copied to clipboard

Adding parentheses will create extra spaces

Open 1925381584 opened this issue 1 year ago • 7 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

zed_aupEzyehSp

Environment

Zed: v0.165.0 (Zed Dev 3019960f83e6852a5b9ce3706f88addce3aa2983) OS: Windows 10.0.19045 Memory: 15.7 GiB Architecture: x86_64 GPU: Intel(R) Iris(R) Xe Graphics || Intel Corporation || 101.5972

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

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

No response

1925381584 avatar Dec 09 '24 07:12 1925381584

Experiencing this issue too in vim mode with any kind of parentheses when using ysw[

everdrone avatar Dec 16 '24 15:12 everdrone

This is still an issue currently: In |foo bar, with | denoting the curser position, pressing ysw) in Vim mode results in (foo )bar instead of the expected (foo) bar.

dominiklohmann avatar Apr 18 '25 20:04 dominiklohmann

From what i've seen, this is intentional, you have to use the closing bracket if you don't want extra spaces.

Also correct me if i'm wrong, but i'm pretty sure the example @dominiklohmann sent is also intentional, and you should use ysiw instead if you don't want it to account for the extra spaces.

https://github.com/zed-industries/zed/blob/main/crates/vim/src/surrounds.rs#L90-L97

vipexv avatar Jun 02 '25 17:06 vipexv

Not sure what you mean with "normal Vim behavior," because there is no such thing as ys in Vim OOTB. The most commonly used plugin for this is tpope/vim-surround, which has the behavior I described.

If I "surround a word" (ysw) with anything, I don't usually want to include something that's not part of the word.

dominiklohmann avatar Jun 02 '25 17:06 dominiklohmann

Not sure what you mean with "normal Vim behavior," because there is no such thing as ys in Vim OOTB. The most commonly used plugin for this is tpope/vim-surround, which has the behavior I described.

If I "surround a word" (ysw) with anything, I don't usually want to include something that's not part of the word.

Correct, i should've pointed that out when i said "Normal Vim Behavior".

And you should use ysiw instead if that's what your looking to do, i'm unsure if they want this to be changed or not, i would be willing to submit a PR that could potentially fix that issue and make it behave the same as tpope/vim-surround.

vipexv avatar Jun 02 '25 17:06 vipexv

I see your point, but I respectfully disagree because I do not think that the behavior you're suggesting is ever useful for the user.

I would argue that going from foo bar to "foo "bar is never what the user intended if they used ysw". To do that, a user should need to use the more explicit ysf<space>" or similar.

dominiklohmann avatar Jun 02 '25 17:06 dominiklohmann

I see your point, but I respectfully disagree because I do not think that the behavior you're suggesting is ever useful for the user.

I would argue that going from foo bar to "foo "bar is never what the user intended if they used ysw". To do that, a user should need to use the more explicit ysf<space>" or similar.

I would agree, and i would be willing to attempt to fix that, but the main concern for me is the fact that they might've intentionally done this for one reason or another, maybe someone from the Zed team could clear up the confusion.

vipexv avatar Jun 02 '25 17:06 vipexv

Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and we will keep it open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, we'll close it in 7 days. Thanks for your help!

github-actions[bot] avatar Oct 01 '25 07:10 github-actions[bot]

This issue was closed due to inactivity. If you're still experiencing this problem, please open a new issue with a link to this issue.

github-actions[bot] avatar Oct 08 '25 09:10 github-actions[bot]