-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash on completion for an alias #12090
Comments
ugh, thanks for reporting it. |
This is kind of strange. calendar<tab> panic calendar <tab> I guess this is just showing the available calendar commands versus showing the parameters for a command. |
@Tastaturtaste or @maxomatic458 do either of you have time to look into this completion bug? |
Can this be taken up by a beginner? @fdncred |
@Ayanrocks it seems to be a logical error. The panic happens here: let mut results = working_set
.find_commands_by_predicate(filter_predicate, true)
.into_iter()
.map(move |x| SemanticSuggestion {
suggestion: Suggestion {
value: String::from_utf8_lossy(&x.0).to_string(),
description: x.1,
style: None,
extra: None,
> span: reedline::Span::new(span.start - offset, span.end - offset),
append_whitespace: true,
},
kind: Some(SuggestionKind::Command(x.2)),
})
.collect::<Vec<_>>();
|
I've traced logic to this calling function which is calling the above code block. This is the original code now 👇🏽 // The last item here would be the earliest shape that could possible by part of this subcommand
let subcommands = if let Some(last) = last {
println!("Coming HERE ---->");
self.complete_commands(
working_set,
Span::new(last.0.start, pos), <- passing new span instead of passing the original span from the arguments
offset,
false,
options.match_algorithm,
)
} Here I traced the issue to this span that we're creating for new instead of passing the original span My Fixes 👇🏽 fix #1 -> self.complete_commands(
working_set,
Span::new(last.0.start, last.0.end), // change here
offset,
false,
options.match_algorithm,
)
OR
fix #2 -> self.complete_commands(
working_set,
span, // change here
offset,
false,
options.match_algorithm,
) Here above ☝🏽 the two possible fixes I could do. Either pass the original span from the arguments of this function or create a new span with |
Any help on this?? |
@Ayanrocks I didn't check everything, but since it is related to |
Raised a PR: #12596 |
This is purely incidental but the command |
even if we change the weekday from |
@Ayanrocks can you replicate this on the latest version (so compiled from current main) of the repo. |
Compiled a fresh main branch after taking a pull. Still the panic is happening. p.s Add a space after |
ah ok, i still tried the old command so Thanks for checking |
Hey @maxomatic458 Can you help me on one doubt, if the offset is the main culprit then what should be the actual value of offset in this case? it has to be less than the We can connect on discord as well if needed more clarification: https://discord.com/channels/601130461678272522/1229901178696106147 |
well i guess the panic is just caused because offset is bigger than either the span start or the span end could be easily fixed by using but i think the root of the problem is probably somewhere else |
Describe the bug
I have an alias to
cal
. When I try to tab-complete outside of half-complete flags, it crashes.How to reproduce
alias calendar = cal --week-start monday
.calendar
and hit tab.Expected behavior
Normal completion.
Screenshots
No response
Configuration
Additional context
Backtrace
The text was updated successfully, but these errors were encountered: