未验证 提交 edb1e2bc 编写于 作者: I Ivan 提交者: GitHub

Handle properly the copy-pasted query with \n at end (#9023)

上级 29a26a87
...@@ -81,7 +81,12 @@ String LineReader::readLine(const String & first_prompt, const String & second_p ...@@ -81,7 +81,12 @@ String LineReader::readLine(const String & first_prompt, const String & second_p
} }
if (input.empty()) if (input.empty())
continue; {
if (!line.empty() && !delimiter && !hasInputData())
break;
else
continue;
}
is_multiline = (input.back() == extender) || (delimiter && input.back() != delimiter) || hasInputData(); is_multiline = (input.back() == extender) || (delimiter && input.back() != delimiter) || hasInputData();
...@@ -96,18 +101,16 @@ String LineReader::readLine(const String & first_prompt, const String & second_p ...@@ -96,18 +101,16 @@ String LineReader::readLine(const String & first_prompt, const String & second_p
line += (line.empty() ? "" : " ") + input; line += (line.empty() ? "" : " ") + input;
if (!is_multiline) if (!is_multiline)
{ break;
if (line != prev_line) }
{
addToHistory(line);
prev_line = line;
}
return line; if (!line.empty() && line != prev_line)
} {
addToHistory(line);
prev_line = line;
} }
return {}; return line;
} }
LineReader::InputStatus LineReader::readOneLine(const String & prompt) LineReader::InputStatus LineReader::readOneLine(const String & prompt)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册