Shell: Fix closest command node detection in Pipes and Sequences

This makes --option completions work for pipes and sequences too.
This commit is contained in:
AnotherTest 2020-10-04 10:51:28 +03:30 committed by Andreas Kling
parent a9cee8ee02
commit 7f3e1fa826

View file

@ -1617,10 +1617,16 @@ HitTestResult Pipe::hit_test_position(size_t offset)
return {};
auto result = m_left->hit_test_position(offset);
if (result.matching_node)
if (result.matching_node) {
if (!result.closest_command_node)
result.closest_command_node = m_right;
return result;
}
return m_right->hit_test_position(offset);
result = m_right->hit_test_position(offset);
if (!result.closest_command_node)
result.closest_command_node = m_right;
return result;
}
Pipe::Pipe(Position position, NonnullRefPtr<Node> left, NonnullRefPtr<Node> right)
@ -1801,9 +1807,16 @@ HitTestResult Sequence::hit_test_position(size_t offset)
return {};
auto result = m_left->hit_test_position(offset);
if (result.matching_node)
if (result.matching_node) {
if (!result.closest_command_node)
result.closest_command_node = m_right;
return result;
return m_right->hit_test_position(offset);
}
result = m_right->hit_test_position(offset);
if (!result.closest_command_node)
result.closest_command_node = m_right;
return result;
}
Sequence::Sequence(Position position, NonnullRefPtr<Node> left, NonnullRefPtr<Node> right, Position separator_position)