mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:47:34 +00:00
Shell: Mark AST::Background as would_execute if its subnode does
This commit is contained in:
parent
2fd9e72264
commit
0676bd4afc
2 changed files with 17 additions and 1 deletions
|
@ -336,7 +336,19 @@ void Background::dump(int level) const
|
||||||
|
|
||||||
RefPtr<Value> Background::run(RefPtr<Shell> shell)
|
RefPtr<Value> Background::run(RefPtr<Shell> shell)
|
||||||
{
|
{
|
||||||
auto commands = m_command->run(shell)->resolve_as_commands(shell);
|
// FIXME: Currently this does not work correctly if `m_command.would_execute()',
|
||||||
|
// as it runs the node, which means nodes likes And and Or will evaluate
|
||||||
|
// all but their last subnode before yielding to this, causing a command
|
||||||
|
// like `foo && bar&` to effectively be `foo && (bar&)`.
|
||||||
|
auto value = m_command->run(shell)->resolve_without_cast(shell);
|
||||||
|
if (value->is_job()) {
|
||||||
|
auto job = static_cast<JobValue*>(value.ptr())->job();
|
||||||
|
job->set_running_in_background(true);
|
||||||
|
job->set_should_announce_exit(true);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto commands = value->resolve_as_commands(shell);
|
||||||
auto& last = commands.last();
|
auto& last = commands.last();
|
||||||
last.should_wait = false;
|
last.should_wait = false;
|
||||||
|
|
||||||
|
@ -1021,6 +1033,9 @@ void Execute::for_each_entry(RefPtr<Shell> shell, Function<IterationDecision(Ref
|
||||||
|
|
||||||
RefPtr<Value> Execute::run(RefPtr<Shell> shell)
|
RefPtr<Value> Execute::run(RefPtr<Shell> shell)
|
||||||
{
|
{
|
||||||
|
if (m_command->would_execute())
|
||||||
|
return m_command->run(shell);
|
||||||
|
|
||||||
NonnullRefPtrVector<Value> values;
|
NonnullRefPtrVector<Value> values;
|
||||||
for_each_entry(shell, [&](auto value) {
|
for_each_entry(shell, [&](auto value) {
|
||||||
values.append(*value);
|
values.append(*value);
|
||||||
|
|
|
@ -458,6 +458,7 @@ private:
|
||||||
virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override;
|
virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override;
|
||||||
virtual HitTestResult hit_test_position(size_t) override;
|
virtual HitTestResult hit_test_position(size_t) override;
|
||||||
virtual String class_name() const override { return "Background"; }
|
virtual String class_name() const override { return "Background"; }
|
||||||
|
virtual bool would_execute() const override { return m_command->would_execute(); }
|
||||||
|
|
||||||
RefPtr<Node> m_command;
|
RefPtr<Node> m_command;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue