Shell: Complete for current path when the text is empty

For example, when typing `cd <tab>`, the shell will show a list of
files in the current directory. This behavior is similar to typing `cd
./<tab>`.

It makes it easier to `cd` into directories without having to list them
first.
This commit is contained in:
Damien Firmenich 2022-04-13 15:25:55 +02:00 committed by Ali Mohammad Pur
parent 9dbcda7eef
commit 31ca48ebb2
Notes: sideshowbarker 2024-07-17 21:16:31 +09:00

View file

@ -392,7 +392,7 @@ Vector<Line::CompletionSuggestion> Node::complete_for_editor(Shell& shell, size_
}
auto result = hit_test_position(offset);
if (!result.matching_node)
return {};
return shell.complete_path("", "", 0, Shell::ExecutableOnly::No, result.closest_command_node.ptr(), nullptr, Shell::EscapeMode::Bareword);
auto node = result.matching_node;
if (node->is_bareword() || node != result.closest_node_with_semantic_meaning)
node = result.closest_node_with_semantic_meaning;