Skip to content

Commit 4f2cccc

Browse files
committed
[lldb/Editline] Fix mistake in HistoryOperation mapping
In 0e9b0b6 I introduced the HistoryOperation enum to navigate the history. While this fixed the behavior of HistoryOperation::Older and HistoryOperation::Newer, it confused the mapping for HistoryOperation::Oldest and HistoryOperation::Newest. I tried to write a PExpect test to make sure this doesn't regress, but I'm unable to prime the history in such a way that it recalls a known element. I suspect this is an LLDB bug, but the most recent entry doesn't get update with entries from the current session. I considered spoofing the home directory but that needs to happen before libLLDB is loaded and you'll need to account for the widechar support. If anyone has another suggestion I'd love to hear it.
1 parent baf9837 commit 4f2cccc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lldb/source/Host/common/Editline.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,32 @@ bool IsOnlySpaces(const EditLineStringType &content) {
9999

100100
static int GetOperation(HistoryOperation op) {
101101
// The naming used by editline for the history operations is counter
102-
// intuitive to how it's used here.
102+
// intuitive to how it's used in LLDB's editline implementation.
103+
//
104+
// - The H_LAST returns the oldest entry in the history.
103105
//
104106
// - The H_PREV operation returns the previous element in the history, which
105107
// is newer than the current one.
106108
//
109+
// - The H_CURR returns the current entry in the history.
110+
//
107111
// - The H_NEXT operation returns the next element in the history, which is
108112
// older than the current one.
109113
//
114+
// - The H_FIRST returns the most recent entry in the history.
115+
//
110116
// The naming of the enum entries match the semantic meaning.
111117
switch(op) {
112118
case HistoryOperation::Oldest:
113-
return H_FIRST;
119+
return H_LAST;
114120
case HistoryOperation::Older:
115121
return H_NEXT;
116122
case HistoryOperation::Current:
117123
return H_CURR;
118124
case HistoryOperation::Newer:
119125
return H_PREV;
120126
case HistoryOperation::Newest:
121-
return H_LAST;
127+
return H_FIRST;
122128
}
123129
llvm_unreachable("Fully covered switch!");
124130
}

0 commit comments

Comments
 (0)