added defaults. fixed but of not loading history. (#2243)

This commit is contained in:
Darren Schroeder 2020-07-23 07:19:05 -05:00 committed by GitHub
parent 9b35aae5e8
commit e3d7e46855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -559,8 +559,8 @@ pub fn set_rustyline_configuration() -> (Editor<Helper>, IndexMap<String, Value>
};
if let Ok(config) = config::config(Tag::unknown()) {
if let Some(batvars) = config.get("line_editor") {
for (idx, value) in batvars.row_entries() {
if let Some(line_editor_vars) = config.get("line_editor") {
for (idx, value) in line_editor_vars.row_entries() {
match idx.as_ref() {
"max_history_size" => {
let max_history_size = match value.as_u64() {
@ -676,8 +676,24 @@ pub fn set_rustyline_configuration() -> (Editor<Helper>, IndexMap<String, Value>
}
}
}
} else {
// if the config section doesn't exist, let's set some defaults
rl.set_max_history_size(1000);
rl.set_history_ignore_dups(true);
rl.set_history_ignore_space(true);
rl.set_completion_type(DEFAULT_COMPLETION_MODE);
rl.set_completion_prompt_limit(1);
rl.set_keyseq_timeout(500);
rl.set_edit_mode(rustyline::config::EditMode::Vi);
rl.set_auto_add_history(true);
rl.set_bell_style(rustyline::config::BellStyle::None);
rl.set_color_mode(rustyline::ColorMode::Enabled);
rl.set_tab_stop(4);
}
// we are ok if history does not exist
let _ = rl.load_history(&History::path());
(rl, config)
}