From 2e1217da4617c832afcd7ca90c88b06c200dc23b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 9 Nov 2016 12:08:49 +0100 Subject: 'inccommand': buftype=nofile, restore cursor/view - Use a standard scratch buffer instead of a new 'buftype', functions like curbufIsChanged() already have special handling for scratch bufs. - Cleanup some stuff from the previous merge. - Add support for :smagic, :snomagic. Closes #5578 --- src/nvim/ex_getln.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 17693ecfc8..8ddb1047c7 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5147,7 +5147,9 @@ static int ex_window(void) cmdwin_type = get_cmdline_type(); // Create empty command-line buffer. - buf_open_special(0, "[Command Line]", "nofile"); + buf_open_scratch(0, "[Command Line]"); + // Command-line buffer has bufhidden=wipe, unlike a true "scratch" buffer. + set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL); curwin->w_p_rl = cmdmsg_rl; cmdmsg_rl = false; curbuf->b_p_ma = true; -- cgit From 795f2bb9b9b4de2d503e7d792bf6a3c47f92b8c5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 10 Nov 2016 15:47:14 +0100 Subject: 'inccommand': Restore cursor/view if cancelled. Restore cursor position and window "view", if command is cancelled. This is how 'incsearch' works. --- src/nvim/ex_getln.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 8ddb1047c7..c4169f03f0 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1599,6 +1599,16 @@ static int command_line_changed(CommandLineState *s) && cmd_is_live(ccline.cmdbuff)) { // process a "live" command ('inccommand') do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_LIVE); + + // restore the window "view" + curwin->w_cursor = s->old_cursor; + curwin->w_curswant = s->old_curswant; + curwin->w_leftcol = s->old_leftcol; + curwin->w_topline = s->old_topline; + curwin->w_topfill = s->old_topfill; + curwin->w_botline = s->old_botline; + update_topline(); + redrawcmdline(); } -- cgit