1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 20:25:07 +00:00

Shell: Make <return> go to a new line when the command is incomplete

"incomplete" meaning that it has a syntax error that can be recovered
from by continuing the input.
This commit is contained in:
AnotherTest 2020-12-01 12:55:14 +03:30 committed by Andreas Kling
parent 48d2545572
commit 5325d6871d
6 changed files with 61 additions and 50 deletions

View file

@ -2481,6 +2481,10 @@ StringPartCompose::~StringPartCompose()
void SyntaxError::dump(int level) const
{
Node::dump(level);
print_indented("(Error text)", level + 1);
print_indented(m_syntax_error_text, level + 2);
print_indented("(Can be recovered from)", level + 1);
print_indented(String::formatted("{}", m_is_continuable), level + 2);
}
RefPtr<Value> SyntaxError::run(RefPtr<Shell>)
@ -2494,9 +2498,10 @@ void SyntaxError::highlight_in_editor(Line::Editor& editor, Shell&, HighlightMet
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Foreground(Line::Style::XtermColor::Red), Line::Style::Bold });
}
SyntaxError::SyntaxError(Position position, String error)
SyntaxError::SyntaxError(Position position, String error, bool is_continuable)
: Node(move(position))
, m_syntax_error_text(move(error))
, m_is_continuable(is_continuable)
{
m_is_syntax_error = true;
}