diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-30 23:19:08 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-30 23:19:08 -0700 |
commit | 7fcaf54de475ec9e06e612a73b4e90f09d641958 (patch) | |
tree | 69950ed0b17c1368c909bc3b103cc9d690cc07dd /linenoise/linenoise.c | |
parent | 654267a6748d56757954f2c97e4178fdfc7c0626 (diff) | |
download | txr-7fcaf54de475ec9e06e612a73b4e90f09d641958.tar.gz txr-7fcaf54de475ec9e06e612a73b4e90f09d641958.tar.bz2 txr-7fcaf54de475ec9e06e612a73b4e90f09d641958.zip |
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.
Diffstat (limited to 'linenoise/linenoise.c')
-rw-r--r-- | linenoise/linenoise.c | 13 |
1 files changed, 12 insertions, 1 deletions
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, |