Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/include/llvm/LineEditor/LineEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class LineEditor {

void saveHistory();
void loadHistory();
void setHistorySize(int size);

static std::string getDefaultHistoryPath(StringRef ProgName);

Expand Down
9 changes: 8 additions & 1 deletion llvm/lib/LineEditor/LineEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#endif

using namespace llvm;
constexpr int DefaultHistorySize = 800;

std::string LineEditor::getDefaultHistoryPath(StringRef ProgName) {
SmallString<32> Path;
Expand Down Expand Up @@ -220,8 +221,8 @@ LineEditor::LineEditor(StringRef ProgName, StringRef HistoryPath, FILE *In,
NULL); // Fix the delete key.
::el_set(Data->EL, EL_CLIENTDATA, Data.get());

setHistorySize(DefaultHistorySize);
HistEvent HE;
::history(Data->Hist, &HE, H_SETSIZE, 800);
::history(Data->Hist, &HE, H_SETUNIQUE, 1);
loadHistory();
}
Expand All @@ -248,6 +249,11 @@ void LineEditor::loadHistory() {
}
}

void LineEditor::setHistorySize(int size) {
HistEvent HE;
::history(Data->Hist, &HE, H_SETSIZE, size);
}

std::optional<std::string> LineEditor::readLine() const {
// Call el_gets to prompt the user and read the user's input.
int LineLen = 0;
Expand Down Expand Up @@ -291,6 +297,7 @@ LineEditor::~LineEditor() {

void LineEditor::saveHistory() {}
void LineEditor::loadHistory() {}
void LineEditor::setHistorySize(int size) {}

std::optional<std::string> LineEditor::readLine() const {
::fprintf(Data->Out, "%s", Prompt.c_str());
Expand Down
Loading