From 183b35d6836a7374fb221778d1184c545a3f8780 Mon Sep 17 00:00:00 2001 From: Lily Mara <6109875+lily-mara@users.noreply.github.com> Date: Fri, 13 Aug 2021 11:56:28 -0700 Subject: [PATCH] Rustyline bug fixes (#3916) * Mitigate history file bug in Rustyline Rustyline's duplicate ignoring code has a bug that can cause data loss and history file corruption. Testing seems to indicate that disabling this behavior and allowing duplicates will prevent the bug from showing up. Many people have complained about this issue, I think it is worthwhile to fix the bug at the cost of permitting duplicate history entries. Upstream bug: https://github.com/kkawakam/rustyline/issues/559 * Increase Rustyline historyfile limit Rustyline will only store 100 history items by default. This is quite a small limit for a shell that people use as a daily driver. Especially when the deduplication code is removed, we will hit that limit quickly and start to lose history. This commit bumps the limit up to 10k. We can discuss if this is an inappropriate limit or if we should allow users to specify this setting in their nushell config file instead. --- crates/nu-cli/src/line_editor.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/nu-cli/src/line_editor.rs b/crates/nu-cli/src/line_editor.rs index c0d7539eb3..7c36021b82 100644 --- a/crates/nu-cli/src/line_editor.rs +++ b/crates/nu-cli/src/line_editor.rs @@ -76,6 +76,8 @@ pub fn default_rustyline_editor_configuration() -> Editor { let config = Config::builder() .check_cursor_position(true) .color_mode(ColorMode::Forced) + .history_ignore_dups(false) + .max_history_size(10_000) .build(); let mut rl: Editor<_> = Editor::with_config(config);