fix(lsp): completion on command with following text (#15238)

# Description

Fixes a bug introduced by #15188 

# User-Facing Changes

Before:

<img width="216" alt="image"
src="https://github.com/user-attachments/assets/5846a844-d88e-4d9f-b9e2-e2478c7acb37"
/>

And will crash the lsp server.

After:

<img width="454" alt="image"
src="https://github.com/user-attachments/assets/85e727d6-fef5-426b-818c-e554d3c49c7d"
/>

# Tests + Formatting

adjusted

# After Submitting
This commit is contained in:
zc he
2025-03-04 19:33:55 +08:00
committed by GitHub
parent 9eaa8908d2
commit de7b000505
2 changed files with 21 additions and 19 deletions

View File

@ -307,6 +307,7 @@ impl NuCompleter {
let need_externals = !prefix_str.contains(' ');
let need_internals = !prefix_str.starts_with('^');
let mut span = element_expression.span;
span.end = std::cmp::min(span.end, pos + 1);
if !need_internals {
span = Span::new(span.start + 1, span.end)
};