X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FTermlib%2FEditor.cc;h=ce6a3fb140dc5a7719b2a2de3d5a3f4fc19fe00c;hb=c45c112ae88196ea8da9c5a9efb0e167196744d2;hp=f3a0c19714110dd8582af21c4f87b790baf7bdaa;hpb=79e54eda6a7fb5ac3fa5b37f408dd386454c5bbd;p=senf.git diff --git a/Utils/Termlib/Editor.cc b/Utils/Termlib/Editor.cc index f3a0c19..ce6a3fb 100644 --- a/Utils/Termlib/Editor.cc +++ b/Utils/Termlib/Editor.cc @@ -346,7 +346,7 @@ prefix_ void senf::term::LineEditor::accept() if (enabled_) newline(); hide(); - pushHistory(text_); + pushHistory(text_, true); callback_(text_); clear(); } @@ -430,15 +430,16 @@ prefix_ void senf::term::LineEditor::insert(std::string const & text) redisplay(); } -prefix_ void senf::term::LineEditor::pushHistory(std::string const & text) +prefix_ void senf::term::LineEditor::pushHistory(std::string const & text, bool accept) { if (! text.empty() - && (historyPoint_ == history_.size() || history_[historyPoint_] != text) + && (accept || historyPoint_ == history_.size() || history_[historyPoint_] != text) && (history_.empty() || history_.back() != text)) { history_.push_back(text); while (history_.size() > MAX_HISTORY_SIZE) history_.erase(history_.begin()); - historyPoint_ = history_.size() - 1; + if (accept) + historyPoint_ = history_.size() - 1; } }