Shell: Use strncmp() instead of string.compare() for name completions

The "at most n bytes" behaviour of strncmp is required for this logic to
work, this was overlooked in 5b64abe when converting Strings to
StringViews, which lead to broken autocomplete.
This commit is contained in:
Ali Mohammad Pur 2022-02-05 14:36:34 +03:30 committed by Ali Mohammad Pur
parent 14d1601a76
commit 222e580fa8
Notes: sideshowbarker 2024-07-17 19:46:43 +09:00

View file

@ -1453,7 +1453,12 @@ Vector<Line::CompletionSuggestion> Shell::complete_program_name(StringView name,
cached_path.span(),
name,
nullptr,
[](auto& name, auto& program) { return name.compare(program.view()); });
[](auto& name, auto& program) {
return strncmp(
name.characters_without_null_termination(),
program.characters(),
name.length());
});
if (!match)
return complete_path("", name, offset, ExecutableOnly::Yes);