Skip to content

Fix completion filtering for multi-character prefixes - #5164

Open
germtb wants to merge 1 commit into
dense-analysis:masterfrom
germtb:fix-completion-multichar-prefixes
Open

germtb wants to merge 1 commit into
dense-analysis:masterfrom
germtb:fix-completion-multichar-prefixes

Conversation

@germtb

@germtb germtb commented Aug 15, 2026

Copy link
Copy Markdown

Fix a bug where ALE was filtering completions after multi-character prefixes (e.g. "::").

rust-analyzer advertises single-characters triggers (this is correct for in the LSP spec: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionContext), but some prefixes are not single characters.

Root cause

  • rust-analyzer advertises :
  • ALE identifies the prefix as ::
  • ALE’s exact comparison fails

Fix

ALE accepts a trigger if it matches the end of a prefix.

Test

I added a regression two assertions to two existing tests that passes now and fail without the fix.

@germtb
germtb requested a review from w0rp as a code owner August 15, 2026 22:09
@hsanson
hsanson requested a balanced review from Copilot August 19, 2026 01:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes completion filtering when a multi-character prefix ends with an LSP trigger character.

Changes:

  • Matches advertised triggers against prefix suffixes.
  • Adds Rust :: regression coverage.
  • Reuses trigger detection during filtering.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
autoload/ale/completion.vim Adds suffix-based trigger matching and filtering.
test/completion/test_completion_filtering.vader Tests :: with rust-analyzer’s : trigger.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread autoload/ale/completion.vim Resolved
@germtb
germtb force-pushed the fix-completion-multichar-prefixes branch from 8d375ce to f503898 Compare August 24, 2026 09:53
@rymdbar

rymdbar commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Thanks for your pull-request!

If I understand things correctly, one way to reproduce this bug would be to run first run:

mkdir /tmp/pr5164
cd /tmp/5164
cargo init
vim src/main.rs

Then enter insert mode and type at the very top of the file:

use std::

Right?

On current master (422c0e8) this will not bring up any completions for me. However on the branch of this pull-request it will. In other words, the fix appears to be working. However I do not exactly understand how.

If going through the description above:

Root cause

  • rust-analyzer advertises :

The LSP communicates:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "capabilities": {
      …
      "completionProvider": {
        "triggerCharacters": [
          ":",
          ".",
          "'",
          "("
        ],
      …
      },
    …
    "serverInfo": {
      "name": "rust-analyzer",
      "version": "2026-06-08"
    }
  }
}

A single character : is included in the array of completionProvider > triggerCharacters, check!

  • ALE identifies the prefix as ::

Does this refer to the second value of s:trigger_character_map.rust? or identifies refers to some actual logic, not merely this assignment of the variable?

  • ALE’s exact comparison fails

Precisely how does it fail? If I understand the previous bullet and s:GetTriggerCharacters() correctly, how ALE defines the fallback should not matter as it is not used. However that variable also ends up in here, and that's where my focus gets lost for now.

What I would want to understand is how ale fails, and how the bug fix works. Until I'm there, I can't vouch for this addressing the core problem. I might be completely off, but it feels a bit odd that hard-coded trigger characters should matter at all when the LSP provides values for them. Maybe that is not what is being claimed? or patched?

Unless someone beats me to it, I intend to look at this again another day.

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.

3 participants