From 2bd77bc93bece47b791a8448db0f6b70003b7831 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 16 Jan 2021 23:20:52 +0330 Subject: Shell: Make the parser read consecutive sequences without recursing This fixes (the easy) part of #4976. --- .../Libraries/LibGUI/ShellSyntaxHighlighter.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'Userland/Libraries/LibGUI') diff --git a/Userland/Libraries/LibGUI/ShellSyntaxHighlighter.cpp b/Userland/Libraries/LibGUI/ShellSyntaxHighlighter.cpp index 8f3c27fa8e..a552764c09 100644 --- a/Userland/Libraries/LibGUI/ShellSyntaxHighlighter.cpp +++ b/Userland/Libraries/LibGUI/ShellSyntaxHighlighter.cpp @@ -380,21 +380,19 @@ private: } virtual void visit(const AST::Sequence* node) override { - { - ScopedValueRollback first_in_command { m_is_first_in_command }; - node->left()->visit(*this); - } - { + for (auto& entry : node->entries()) { ScopedValueRollback first_in_command { m_is_first_in_command }; - node->right()->visit(*this); + entry.visit(*this); } - auto& span = span_for_node(node); - span.range.set_start({ node->separator_position().start_line.line_number, node->separator_position().start_line.line_column }); - set_offset_range_end(span.range, node->separator_position().end_line); - span.attributes.color = m_palette.syntax_punctuation(); - span.attributes.bold = true; - span.is_skippable = true; + for (auto& position : node->separator_positions()) { + auto& span = span_for_node(node); + span.range.set_start({ position.start_line.line_number, position.start_line.line_column }); + set_offset_range_end(span.range, position.end_line); + span.attributes.color = m_palette.syntax_punctuation(); + span.attributes.bold = true; + span.is_skippable = true; + } } virtual void visit(const AST::Subshell* node) override { -- cgit v1.2.3