diff options
author | Nicholas Cellino <nacellin@buffalo.edu> | 2022-03-22 23:33:34 -0400 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2022-03-23 15:27:09 -0400 |
commit | 0e51d9932279ada81c1d69091e09c82d854d8266 (patch) | |
tree | 3c385810109dc86205ac340bf2f3d6811825333a /Userland/Utilities/sql.cpp | |
parent | d6eeb05bf994a3cdb897e5bb6665c570d4eae5b6 (diff) | |
download | serenity-0e51d9932279ada81c1d69091e09c82d854d8266.zip |
sql: Do not indent next line when current one is blank
Previously, if a user pressed Enter without typing a command at
the SQL REPL, the next line would be automatically indented. This
change makes it so we check if there were any tokens in the command
before applying the indentation logic.
Diffstat (limited to 'Userland/Utilities/sql.cpp')
-rw-r--r-- | Userland/Utilities/sql.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Utilities/sql.cpp b/Userland/Utilities/sql.cpp index 4d78668736..c1fea41d30 100644 --- a/Userland/Utilities/sql.cpp +++ b/Userland/Utilities/sql.cpp @@ -227,8 +227,10 @@ private: bool is_first_token = true; bool is_command = false; bool last_token_ended_statement = false; + bool tokens_found = false; for (SQL::AST::Token token = lexer.next(); token.type() != SQL::AST::TokenType::Eof; token = lexer.next()) { + tokens_found = true; switch (token.type()) { case SQL::AST::TokenType::ParenOpen: ++m_repl_line_level; @@ -251,7 +253,8 @@ private: is_first_token = false; } - m_repl_line_level = last_token_ended_statement ? 0 : (m_repl_line_level > 0 ? m_repl_line_level : 1); + if (tokens_found) + m_repl_line_level = last_token_ended_statement ? 0 : (m_repl_line_level > 0 ? m_repl_line_level : 1); } while ((m_repl_line_level > 0) || piece.is_empty()); return piece.to_string(); |