[Lldb-commits] [PATCH] D108983: [lldb] Don't save empty expressions in the multiline editor history
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 31 09:51:40 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f7fb13f87e1: [lldb] Don't save empty expressions in the multiline editor history (authored by teemperor).
Herald added a subscriber: lldb-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108983/new/
https://reviews.llvm.org/D108983
Files:
lldb/source/Host/common/Editline.cpp
lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
Index: lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
===================================================================
--- lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
+++ lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
@@ -76,22 +76,32 @@
@skipIfEditlineSupportMissing
@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr48316')
@skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot
- def test_nav_arrow_up_empty_pr49845(self):
- """Tests that navigating with the up arrow doesn't crash."""
+ def test_nav_arrow_up_empty(self):
+ """
+ Tests that navigating with the up arrow doesn't crash and skips
+ empty history entries.
+ """
self.launch()
- # Create an empty history session by only entering a newline.
+ # Create a real history entry '456' and then follow up with an
+ # empty entry (that shouldn't be saved).
+ self.child.sendline("expr")
+ self.child.expect_exact("terminate with an empty line to evaluate")
+ self.child.send("456\n\n")
+ self.expect_prompt()
+
self.child.sendline("expr")
self.child.expect_exact("terminate with an empty line to evaluate")
self.child.send("\n")
self.expect_prompt()
- # Send just the up arrow in the expression evaluator. This should bring up the previous empty expression.
+ # The up arrow should recall the actual history entry and not the
+ # the empty entry (as that one shouldn't have been saved).
self.child.sendline("expr")
self.child.expect_exact("terminate with an empty line to evaluate")
self.child.send(self.arrow_up)
- self.child.expect_exact("1: ")
- self.child.send("\n")
+ self.child.expect_exact("456")
+ self.child.send("\n\n")
self.expect_prompt()
self.quit()
Index: lldb/source/Host/common/Editline.cpp
===================================================================
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1554,8 +1554,10 @@
interrupted = m_editor_status == EditorStatus::Interrupted;
if (!interrupted) {
- // Save the completed entry in history before returning
- m_history_sp->Enter(CombineLines(m_input_lines).c_str());
+ // Save the completed entry in history before returning. Don't save empty
+ // input as that just clutters the command history.
+ if (m_input_lines.size() > 1 || !m_input_lines.front().empty())
+ m_history_sp->Enter(CombineLines(m_input_lines).c_str());
lines = GetInputAsStringList();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108983.369724.patch
Type: text/x-patch
Size: 2763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210831/3eb45b72/attachment.bin>
More information about the lldb-commits
mailing list