Don't crash completion on unrecognized cursor contexts - #1273
Merged
Conversation
Code.Fragment.cursor_context/1 gains new context types with Elixir releases (:capture_arg in 1.17, :block_keyword_or_binary_operator in 1.18) and do_expand/5 raised CaseClauseError on anything it did not know, taking down the LSP completion request and the debug adapter's completions request. Fall back to no suggestions instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Values bound by rescue are always exception structs, so the guard made the if's else branch unreachable and Elixir 1.20's type checker flagged it, failing the warnings-as-errors CI step. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
lukaszsamson
force-pushed
the
completion-engine-unknown-cursor-context
branch
from
August 16, 2026 05:30
a3cef85 to
203202d
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.
A debug adapter
completionsrequest crashed on 0.30.0 with:That specific context is already handled on master (a234035, released in v0.31.0), but the underlying fragility isn't:
Code.Fragment.cursor_context/1gains new context types with Elixir releases (:capture_argin 1.17,:block_keyword_or_binary_operatorin 1.18), anddo_expand/5raisesCaseClauseErroron anything it doesn't know — killing the LSP completion request or the debug adapter'scompletionsrequest rather than just returning nothing.This adds a catch-all clause that falls back to no suggestions.
mix testinapps/elixir_ls_utilspasses except for one pre-existing failure unrelated to this change (complete built in functions on non local calls, which trips over the new__to_existing_atom__/2builtin on Elixir 1.21-dev).🤖 Generated with Claude Code