fix(lsp): a panic caused by completion with decl_id out of range (#15576)

Fixes a bug caused by #15536 
Sorry about that, @fdncred 

# Description

I've made the panic reproducible in the test case.

TLDR: completer will sometimes return new decl_ids outside of the range
of the engine_state passed in.

# User-Facing Changes

bug fix

# Tests + Formatting

+1

# After Submitting
This commit is contained in:
zc he
2025-04-16 19:43:21 +08:00
committed by GitHub
parent 24cc2f9d87
commit cd4560e97a
3 changed files with 66 additions and 44 deletions

View File

@ -69,7 +69,8 @@ impl Completer for ExportableCompletion<'_> {
wrapped_name(name),
Some(cmd.description().to_string()),
None,
SuggestionKind::Command(cmd.command_type(), Some(*decl_id)),
// `None` here avoids arguments being expanded by snippet edit style for lsp
SuggestionKind::Command(cmd.command_type(), None),
);
}
}