zed
zed copied to clipboard
"g q" doesn't respect leading asterisks in doc comments in TypeScript
Summary
In a TypeScript file, when wrapping comment text in a doc comment (/** .. */) using g q or g q q, the leading asterisks are not inserted as necessary.
Given this block of code:
/**
* Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text. Here's some text.
*/
function foo() {}
Actual result
Placing the cursor on line 2 and typing g q q results in this:
/**
* Here's some text. Here's some text. Here's some text. Here's some text.
Here's some text. Here's some text. Here's some text. Here's some text. Here's
some text. Here's some text. Here's some text. Here's some text. Here's some
text. Here's some text. Here's some text. Here's some text. Here's some text.
Here's some text. Here's some text. Here's some text.
*/
function foo() {}
Expected result: VSCodeVim produces
/**
* Here's some text. Here's some text. Here's some text. Here's some text.
* Here's some text. Here's some text. Here's some text. Here's some text.
* Here's some text. Here's some text. Here's some text. Here's some text.
* Here's some text. Here's some text. Here's some text. Here's some text.
* Here's some text. Here's some text. Here's some text. Here's some text.
*/
function foo() {}
I'm filing this as a bug since it seems to be unique to block/doc comments in TS. Double-slash comments get wrapped correctly (as do triple-slash comments in Rust files).
Possibly/possibly not related: when extend_comment_on_newline is enabled, pressing Return within a TS doc comment doesn't insert the leading asterisk. Triple-slashes in Rust files get inserted correctly.
Zed Version and System Specs
Zed: v0.180.2 (Zed) OS: macOS 15.3.2 Memory: 64 GiB Architecture: aarch64
I believe this has been fixed by:
- https://github.com/zed-industries/zed/pull/30800
And will be available in Zed Preview tomorrow. Thanks for reporting.
@notpeter, @smitbarmase
Saw this in the release notes for 0.188.3. Trying it both in Preview 0.189.2 and regular Zed 0.188.4. I don't see any change in behaviour. There's no automatic asterisk insertion in any .js or .ts files, whether remote or local, and g q still works the way it does in my original report. I do get // insertion on a newline, so the extend_comment_on_newline setting is definitely on. Is there something else that needs to be enabled?
I see. I'm reopening this as mentioned PR only adds the ability to add asterisks on new lines and not when wrapping text, which you are trying to achieve.
Thanks. FWIW, I'm not getting the asterisks on new lines either.
Are you using Vim to add new line?
Are you using Vim to add new line?
I've tried with and without vim mode.
Can you provide a video reproducing it? It is working just fine for me. Maybe certain edge cases we are not taking into consideration.
https://github.com/user-attachments/assets/f0f3e000-0c95-4a10-9c11-85ab0264a8ef
Strange. Can you provide your settings.json?
I've narrowed it down a bit. Thanks for bearing with me.
- Asterisk insertion only works when
use_autocloseistrue. I usually have this disabled. - Once
use_autocloseis enabled, the insertion only happens (for me) when pressing Enter. It doesn't work when the line is added withoorOin Vim mode.
For double-slash comments, the // gets inserted regardless of the value of use_autoclose, and it works when o/O are used as well. That's why I was surprised the asterisk insertion feature doesn't work the same way.