Guard struct completion against non-charlist cursor contexts#44
Open
mariari wants to merge 1 commit into
Open
Conversation
9cbfa7d to
19e86ca
Compare
Code.Fragment.cursor_context/1 returns {:struct, hint} where hint is
only a charlist for a plain alias prefix (%MapS). For %__MODULE__ it
returns {:struct, {:local_or_var, _}}, for %File. {:struct, {:dot,
{:alias, _}, _}}, and for %@attr {:struct, {:module_attribute, _}}.
Passing hint straight to List.to_string/1 crashed the /COMPLETE
handler on every non-charlist shape (e.g. typing %__MODULE__).
Flatten each context tuple to a prefix string with struct_prefix/1 and
complete from there: dotted aliases list submodule structs (%File. ->
File.Stat) and the 0-arity Kernel special forms (%__MOD -> __MODULE__)
complete, sourced from Kernel.SpecialForms rather than naming any one.
Shapes with no struct name (a bare variable or module attribute)
complete to nothing instead of crashing.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
19e86ca to
194cd61
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code completion would fail on stuff like %MODULE
with an error like
this patch seeks to rectify this issue