Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: src/d8-readline.cc

Issue 7885026: Fixing d8's broken readline history. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed a presubmit issue. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8-readline.cc
diff --git a/src/d8-readline.cc b/src/d8-readline.cc
index 8422783407f94fb56933da0794081f20bcdbe251..8bcaf5f4e1416b4d7ba00e25eeba9921c709e0d7 100644
--- a/src/d8-readline.cc
+++ b/src/d8-readline.cc
@@ -72,6 +72,7 @@ bool ReadLineEditor::Open() {
rl_completer_word_break_characters = kWordBreakCharacters;
rl_bind_key('\t', rl_complete);
using_history();
+ stifle_history(Shell::kMaxHistoryEntries);
return read_history(Shell::kHistoryFileName) == 0;
}
@@ -88,6 +89,18 @@ i::SmartArrayPointer<char> ReadLineEditor::Prompt(const char* prompt) {
void ReadLineEditor::AddHistory(const char* str) {
+ // Do not record empty input.
+ if (strlen(str) == 0) return;
+ // Remove duplicate history entry.
+ history_set_pos(0);
+ if (current_history()) {
+ do {
+ if (strcmp(current_history()->line, str) == 0) {
+ remove_history(where_history());
+ break;
+ }
+ } while (next_history());
+ }
add_history(str);
}
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698