Skip to content

Don't crash completion on unrecognized cursor contexts - #1273

Merged
lukaszsamson merged 2 commits into
masterfrom
completion-engine-unknown-cursor-context
Aug 16, 2026
Merged

Don't crash completion on unrecognized cursor contexts#1273
lukaszsamson merged 2 commits into
masterfrom
completion-engine-unknown-cursor-context

Conversation

@lukaszsamson

Copy link
Copy Markdown
Collaborator

A debug adapter completions request crashed on 0.30.0 with:

** (CaseClauseError) no case clause matching: {:block_keyword_or_binary_operator, ~c"end"}
    (elixir_ls_utils 0.30.0) lib/completion_engine.ex:134: ElixirLS.Utils.CompletionEngine.do_expand/5

That specific context is already handled on master (a234035, released in v0.31.0), but the underlying fragility isn't: 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 raises CaseClauseError on anything it doesn't know — killing the LSP completion request or the debug adapter's completions request rather than just returning nothing.

This adds a catch-all clause that falls back to no suggestions.

mix test in apps/elixir_ls_utils passes 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__/2 builtin on Elixir 1.21-dev).

🤖 Generated with Claude Code

lukaszsamson and others added 2 commits August 16, 2026 07:30
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
lukaszsamson force-pushed the completion-engine-unknown-cursor-context branch from a3cef85 to 203202d Compare August 16, 2026 05:30
@lukaszsamson
lukaszsamson merged commit 68df44b into master Aug 16, 2026
23 checks passed
@lukaszsamson
lukaszsamson deleted the completion-engine-unknown-cursor-context branch August 16, 2026 05:57
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