diff options
-rw-r--r-- | linenoise/linenoise.c | 5 | ||||
-rw-r--r-- | linenoise/linenoise.h | 1 | ||||
-rw-r--r-- | parser.c | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 92a5b0e7..67af527c 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -2798,6 +2798,11 @@ int lino_hist_load(lino_t *ls, const wchar_t *filename) { return 0; } +int lino_have_new_lines(lino_t *ls) +{ + return ls->history_len > ls->loaded_lines; +} + void lino_set_result(lino_t *ls, wchar_t *res) { lino_os.free_fn(ls->result); diff --git a/linenoise/linenoise.h b/linenoise/linenoise.h index 05f66632..da6e93de 100644 --- a/linenoise/linenoise.h +++ b/linenoise/linenoise.h @@ -115,6 +115,7 @@ int lino_hist_add(lino_t *, const wchar_t *line); int lino_hist_set_max_len(lino_t *, int len); int lino_hist_save(lino_t *, const wchar_t *filename, int new_only); int lino_hist_load(lino_t *, const wchar_t *filename); +int lino_have_new_lines(lino_t *); void lino_set_result(lino_t *, wchar_t *); /* takes ownership of malloced mem; modifies it */ int lino_clear_screen(lino_t *); void lino_set_multiline(lino_t *, int ml); @@ -1330,7 +1330,7 @@ static void hist_save(lino_t *ls, val in_stream, val out_stream, val histfile, const wchar_t *histfile_w, val hist_len_var) { - if (histfile_w) { + if (histfile_w && lino_have_new_lines(ls)) { val histfile_tmp = format(nil, lit("~a.tmp"), histfile, nao); const wchar_t *histfile_tmp_w = c_str(histfile_tmp); lino_t *ltmp = lino_make(coerce(mem_t *, in_stream), |