1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

Shell: Make program-based completion with no actual token possible

31ca48e made this default to paths, but now that we have a few sensible
ways to complete things, let's make those work too.
For instance, prior to this `kill <tab>` would've suggested paths, but
now it will suggest processes.
This commit is contained in:
Ali Mohammad Pur 2022-04-16 03:18:56 +04:30 committed by Ali Mohammad Pur
parent 302a0c54f0
commit ae27d7e442
2 changed files with 6 additions and 3 deletions

View file

@ -393,6 +393,7 @@ Vector<Line::CompletionSuggestion> Node::complete_for_editor(Shell& shell, size_
auto result = hit_test_position(offset);
if (!result.matching_node)
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;
@ -744,6 +745,8 @@ HitTestResult CastToCommand::hit_test_position(size_t offset) const
auto result = m_inner->hit_test_position(offset);
if (!result.closest_node_with_semantic_meaning)
result.closest_node_with_semantic_meaning = this;
if (!result.closest_command_node && position().contains(offset))
result.closest_command_node = this;
return result;
}