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

macro_rules snippet not fully parsed #6347

Closed
gabydd opened this issue Mar 17, 2023 · 1 comment · Fixed by #6371
Closed

macro_rules snippet not fully parsed #6347

gabydd opened this issue Mar 17, 2023 · 1 comment · Fixed by #6371
Labels
C-bug Category: This is a bug
Milestone

Comments

@gabydd
Copy link
Member

gabydd commented Mar 17, 2023

Summary

Because an error is now returned if the whole snippet is not parsed and some snippets are not getting parsed fully like the macro_rules snippet from rust analyzer, which means those snippets are not applied.
@pascalkuthe wrote the pr that discards snippets of they aren't fully parsed, and he suspects it's a seperate bug, because we should always fully parse a snippet unless the snippet is incorrect.

Reproduction Steps

I tried this:

  1. hx
  2. Open a rust file
  3. Type macro_ru
  4. Tab till you get the macro_rules snippet

I expected this to happen:
Snippeted is applied
Instead, this happened:
Document stays the same and error is added to log file

Helix log

~/.cache/helix/helix.log
2023-03-17T07:04:41.302 helix_term::ui::completion [ERROR] Failed to parse snippet: "macro_rules! $1 {\n    ($2) => {\n        $0\n    };\n}", remaining output: Failed to parse snippet. Remaining input: };
}

Platform

Linux and Android

Terminal Emulator

Kitty and termux

Helix Version

22.12-434-g21a3fb8f

@gabydd gabydd added the C-bug Category: This is a bug label Mar 17, 2023
@pascalkuthe
Copy link
Member

Thanks for reporting, what's causing this issue is that the snippet code currently requires } to be escaped.

From the spec:

With \ (backslash), you can escape $, } and . Within choice elements, the backslash also escapes comma and pipe characters.

I assumed that means that } always needs to be escaped but I guess thats only true in a context where }has special syntactic meaning.

Fixing this should be quite easy but I want to look at vscode again to catch all the details of how they handle this. The standard is so vague here that snippets are essentially defined by what vscode does. I will be traveling this weekend so I might only get a chance to do that next week

@archseer archseer added this to the next milestone Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants