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

Robust snippet parsing #6371

Merged
merged 5 commits into from
Mar 22, 2023

Conversation

pascalkuthe
Copy link
Member

@pascalkuthe pascalkuthe commented Mar 19, 2023

Closes #6347

Fixes a bunch of small bugs in the snippet parsing, mostly relating to escape sequences. The LSP standard is incomplete, ambigous/missleading and sometimes even downright wrong so I just used the vscode implementation as a reference. I have started porting a bunch of tests over from there to be sure we are doing the right thing now. However due to the sheer number of tests I stopped with that at some point to preserver my sanity.

The large number of inserted lines are just tests, the code changes itself are pretty minor.

@pascalkuthe pascalkuthe added C-bug Category: This is a bug E-medium Call for participation: Experience needed to fix: Medium / intermediate S-waiting-on-review Status: Awaiting review from a maintainer. A-language-server Area: Language server client labels Mar 19, 2023
@pascalkuthe pascalkuthe added this to the next milestone Mar 19, 2023
Copy link
Contributor

@Urgau Urgau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

fn anything<'a>(escape_chars: &'static [char]) -> impl Parser<'a, Output = SnippetElement<'a>> {
fn anything<'a>(
escape_chars: &'static [char],
end_at_brace: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool as parameter aren't pretty. Maybe directly specifying a const instead?

Suggested change
end_at_brace: bool,
extra_chars: &'static [char],

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer bool parameters to const generics. There is some prior discussion of it in the reviews of #3890 and #5420

Copy link
Member Author

@pascalkuthe pascalkuthe Mar 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, I meant to answer this but somehow my comment didn't get posted. Even with const generics this is not that easy to do since we need to add $ to the slice. It's possible to do this with a bunch of fancy array tricks + const generic magic (or by allocating a vec) but I think a simple bool parameter is preferable to that. If we actually need something else than a bracket here we can revisit

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for expanding the test cases, this looks great!

@archseer archseer merged commit f9a25a7 into helix-editor:master Mar 22, 2023
@pascalkuthe pascalkuthe deleted the robust_snippet_parsing branch May 12, 2023 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-bug Category: This is a bug E-medium Call for participation: Experience needed to fix: Medium / intermediate S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macro_rules snippet not fully parsed
4 participants