1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +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

@ -1678,9 +1678,9 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s
completion_command.argv.extend({ "--complete", "--" });
struct Visitor : public AST::NodeVisitor {
Visitor(Shell& shell, AST::Node const& node)
Visitor(Shell& shell, AST::Position position)
: shell(shell)
, completion_position(node.position())
, completion_position(position)
{
lists.empend();
}
@ -1824,7 +1824,7 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s
virtual void visit(AST::ReadWriteRedirection const*) override { }
virtual void visit(AST::WriteAppendRedirection const*) override { }
virtual void visit(AST::WriteRedirection const*) override { }
} visitor { *this, *node };
} visitor { *this, node ? node->position() : AST::Position() };
command_node->visit(visitor);
if (visitor.fail)