Closed ComplexPlane closed 6 days ago
So many words, and no actionable details.
What is the language in question?
Do you have non-default settings for that language? (e.g. format_on_save
may insert extra things like braces)
What are the autoclose examples where "auto-insert brace/paren/bracket support" works differently in VSCode and Zed? Ideally, in the format "before" -> "after" in the text/screenshot form.
Sorry if I got a little carried away.
I'm using Rust, and I've just reproduced it on default settings. Here's a couple demos:
With the following code:
pub fn switch_choice(&self) {
match MyEnum::try_from(pref::get(pref::U8Pref::Choice) as u32).unwrap() {
MyEnum::Default => (),
MyEnum::Random => {
mkb::active_monkey_id[mkb::curr_player_idx as usize] = mkb::rand() % 4 as u32;
}
}
}
Zed:
https://github.com/user-attachments/assets/2c69cd3c-49a6-4804-9bbf-c2c6c6461286
VSCode:
https://github.com/user-attachments/assets/1393130e-6d22-4283-b494-c9ad3d0335ef
This time, when a left paren is inserted which matches an existing right paren, an additional right paren is still inserted which restores the imbalance.
Zed:
https://github.com/user-attachments/assets/81b4377e-9276-4cf9-870c-9cede0d38930
VSCode:
https://github.com/user-attachments/assets/9931316e-e671-4509-a8c3-75c73393a323
Thank you, this is much more clear.
And it seems that the main issue here is rust-analyzer LSP server and its autoformatting capabilities. Ironically, it's me who spoiled that for you: https://github.com/rust-lang/rust-analyzer/pull/15532 There definitely should be more heuristics added there, but it's somewhat hard to grasp properly. Maybe, some trigger characters config there would be ok as a semi-fix?
But at least you can turn it off entirely by changing this default: https://github.com/zed-industries/zed/blob/ebc3031fd9d01f872f68f3ef9f56bad52a885caa/assets/settings/default.json#L166-L168
This does not disable Zed's bracket completion and it will still autoclose brackets that were just typed and have no text after them, but stops rust-analyzer from autoclosing the brackets with some text between those.
Thanks, that setting does seem to match my expectations for now. It does seem like a tricky problem to fix properly.
Check for existing issues
Describe the feature
First off, Zed is awesome and I love using it full-time, so thank you very much for making Zed!
That being said, I find myself constantly annoyed with Zed's auto-insert brace/paren/bracket support. I believe VSCode will only do this if the closing character pos is the next adjacent character, and not attempt it otherwise. OTOH, Zed will very often try to insert a matching right character far away from the inputted left character, in an unintended position at least 50% of the time. I don't want to turn it off because matching the adjacent character like VSCode is still useful.
I personally find it very frustrating to hunt for and delete Zed's incorrect autoclosed character constantly, and AFAIK it's not really possible to reasonably guess where it should go, except in the simple directly adjacent case. It's sufficiently annoying and frequently incorrect that I don't think it should be the default behavior. IMO there should at least be an option to be more conservative.
If applicable, add mockups / screenshots to help present your vision of the feature
No response