From 7fcaf54de475ec9e06e612a73b4e90f09d641958 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 30 Sep 2015 23:19:08 -0700 Subject: linenoise: fix multi-line issue in history search. Aborting a multi-line search result with Ctrl-C messes up display because the row-related values are being done on a linenoise copy, and their latest values aren't backpropagated to the master lino_t. * linenoise/linenoise.c (copy_display_params): New static function. (history_search): Use the lino_t copy when clearing the screen, because lino_clear_screen manipulates a display parameter. When leaving the function, copy the latest display-related parameters from lc to l, so that l has the latest number of columns and all the right row stuff for multi-line mode. --- linenoise/linenoise.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'linenoise/linenoise.c') diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index cafa7e0a..01e48ed9 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -578,6 +578,8 @@ static int next_hist_match(lino_t *l, char *pat, int cur, size_t *offs) return -1; } +static void copy_display_params(lino_t *, const lino_t *); + static int history_search(lino_t *l) { char hpat[128] = ""; @@ -688,7 +690,7 @@ static int history_search(lino_t *l) vb = 1; continue; case CTL('L'): - lino_clear_screen(l); + lino_clear_screen(lc); break; case CTL('Z'): disable_raw_mode(l); @@ -701,6 +703,7 @@ static int history_search(lino_t *l) } out: + copy_display_params(l, lc); lino_free(lc); lino_free(ld); refresh_line(l); @@ -793,6 +796,14 @@ static void sync_data_to_buf(lino_t *l) *bptr++ = 0; } +static void copy_display_params(lino_t *to, const lino_t *from) +{ + to->mlmode = from->mlmode; + to->cols = from->cols; + to->oldrow = from->oldrow; + to->maxrows = from->maxrows; +} + /* Single line low level line refresh. * * Rewrite the currently edited line accordingly to the buffer content, -- cgit v1.2.3