zed icon indicating copy to clipboard operation
zed copied to clipboard

Autocomplete replaces the existing expression incorrectly JS/TS

Open v57 opened this issue 9 months ago • 2 comments

Summary

Autocomplete replaces the existing expression instead of wrapping it when accepting a suggestion.

Steps to trigger the problem:

Type the following code in Zed (JS/TS):

this.value

Place the cursor before this.value. Start typing Math.ro and press Enter to accept the Math.round autocomplete suggestion.

Actual Behavior: The code is transformed into:

Math.round(|x|).value // Cursor selection marked by |

Zed inserts Math.round(x) instead of correctly wrapping the existing expression.

Expected Behavior: The code should transform into:

Math.round(this.value)|

or

some = Math.round|this.value // Current behavior in VSCode

Autocomplete should wrap this.value instead of replacing it with a generic placeholder.

videos

https://github.com/user-attachments/assets/c10c6340-8fc8-404f-8f33-4362564f23cc

https://github.com/user-attachments/assets/1e1741f0-3369-4b60-8fbd-b150494abf4f

Zed Version and System Specs

Zed: v0.178.5 (Zed) OS: macOS 15.3.2 Memory: 18 GiB Architecture: aarch64

v57 avatar Mar 24 '25 06:03 v57

I can reproduce. I'm not sure the auto-surround behavior Math.round(this.value) would be the desired behavior in all circumstances, but Zed clobbering the next token (this in your example) definitely seems broken.

Thanks for reporting.

notpeter avatar Mar 24 '25 13:03 notpeter

Another example of Zed clobbering the next token (this has basically been the case for several months, at least in Python code bases):

https://github.com/user-attachments/assets/bc57034c-bbe9-4b9c-88e1-e78d531c5e23

darsnack avatar May 16 '25 14:05 darsnack

Hi there! 👋 We're working to clean up our issue tracker by closing older bugs 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 it will be kept open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, it will close automatically in 14 days. Thanks for your help!

github-actions[bot] avatar Nov 19 '25 09:11 github-actions[bot]