Skip to content

Fix completion for record dot syntax when record isn't known #4619

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samuel-williams-da
Copy link

@samuel-williams-da samuel-williams-da commented Jun 7, 2025

The issue was that the prefix info extractor didn't check that the "modName" it pulls out is a valid module name, so would include cases when using record dot syntax.
This is only an issue when the record type beforehand's type isn't known , i.e. undefined.myField, as otherwise the incorrect completions were replaced with the field names directly.

Fixes #4405

Copy link
Collaborator

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

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

nice!

@@ -912,7 +912,7 @@ getCompletionPrefixFromRope pos@(Position l c) ropetext =
[] -> Nothing
(x:xs) -> do
let modParts = reverse $ filter (not .T.null) xs
modName = T.intercalate "." modParts
modName = if all (isUpper . T.head) modParts then T.intercalate "." modParts else ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you include some explanation for why this is the right thing to do? You explain it nicely in the PR description but it'll get lost if we don't write it in!

Copy link
Author

Choose a reason for hiding this comment

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

Ah yes of course, will do!
Currently fighting CI 😅

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.

Completing record selectors with RecordDotSyntax inserts invalid imports instead
2 participants