Skip to content

Fix autocompletion in template expressions. #483

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

Merged
merged 7 commits into from
Jul 9, 2022
Merged

Fix autocompletion in template expressions. #483

merged 7 commits into from
Jul 9, 2022

Conversation

cristianoc
Copy link
Collaborator

@cristianoc cristianoc commented Jul 8, 2022

The issue turns out to be the location information given by the parser.
This was fixed in the syntax repo and synched here.

See #480

posCursor:[402:22] posNoWhite:[402:20] Found expr:[401:16->402:27]
Pexp_apply ...__ghost__[0:-1->0:-1] (...[400:14->401:16], ...[401:16->402:24])
posCursor:[402:22] posNoWhite:[402:20] Found expr:[401:16->402:24]
Completable: Cnone
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This does not -- it never finds that it's possible to complete here.
Need to see what code the template parser generates. It's a big string append, and also need to check that the locations are correct or this will never be found.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

While before there was an ident inside ghosts, it does not seem the case here.
Either there isn't one based on location, or there is an is not found.

So far this works only if the cursor is *after* the first character.

This will later need to be moved to the syntax repo and synched back.
@cristianoc
Copy link
Collaborator Author

cristianoc commented Jul 9, 2022

So this is progress so far.
One remaining issue is that parsing TemplateTail and TemplatePart is too coarse. By the time control goes back to the parser, the position went beyond where it should go.
For example in `color: ${red}; ` the parser position is on the r instead of being before $.

@cristianoc
Copy link
Collaborator Author

cristianoc commented Jul 9, 2022

The location is now more accurate.

posCursor:[402:24] posNoWhite:[402:23] Found expr:[400:14->402:31]
Pexp_apply ...__ghost__[0:-1->0:-1] (...[401:16->402:27], ...[402:27->402:31])
posCursor:[402:24] posNoWhite:[402:23] Found expr:[401:16->402:27]
Pexp_apply ...__ghost__[0:-1->0:-1] (...[401:16->402:27], ...[402:24->402:27])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mmm looks like this is a ++ b and the locations of the two overlap. Something does not look right in the locations provided by the parser.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we go on exploring the first expression while we should explore the second one.

@cristianoc
Copy link
Collaborator Author

This now works as expected. Need to move the changes to the syntax repo.

@cristianoc cristianoc changed the title Completion template test. Fix autocompletion in template expressions. Jul 9, 2022
cristianoc added a commit to rescript-lang/syntax that referenced this pull request Jul 9, 2022
@cristianoc cristianoc merged commit 42833ed into master Jul 9, 2022
@cristianoc cristianoc deleted the temp-com branch July 26, 2022 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant