mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 12:49:13 +02:00
fix: panic on completion for an alias (#12090)
This commit is contained in:
@@ -186,6 +186,9 @@ impl Completer for CommandCompletion {
|
||||
|
||||
// The last item here would be the earliest shape that could possible by part of this subcommand
|
||||
let subcommands = if let Some(last) = last {
|
||||
// we'll check if start of span is greater than offset, to prevent panic
|
||||
// else we can use the start and end values from last and use that.
|
||||
if last.0.start >= offset {
|
||||
self.complete_commands(
|
||||
working_set,
|
||||
Span::new(last.0.start, pos),
|
||||
@@ -193,6 +196,15 @@ impl Completer for CommandCompletion {
|
||||
false,
|
||||
options.match_algorithm,
|
||||
)
|
||||
} else {
|
||||
self.complete_commands(
|
||||
working_set,
|
||||
Span::new(last.0.start, last.0.end),
|
||||
offset,
|
||||
false,
|
||||
options.match_algorithm,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
Reference in New Issue
Block a user