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/buffer.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 75caf2223b..8e6066453c 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -5273,14 +5273,20 @@ wipe_buffer ( } } -/// Creates or switches to a special-purpose buffer. +/// Creates or switches to a scratch buffer. :h special-buffers +/// Scratch buffer is: +/// - buftype=nofile bufhidden=hide noswapfile +/// - Always considered 'nomodified' /// /// @param bufnr Buffer to switch to, or 0 to create a new buffer. -void buf_open_special(handle_T bufnr, char *bufname, char *buftype) +/// +/// @see curbufIsChanged() +void buf_open_scratch(handle_T bufnr, char *bufname) { (void)do_ecmd((int)bufnr, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL); (void)setfname(curbuf, (char_u *)bufname, NULL, true); - set_option_value((char_u *)"bt", 0L, (char_u *)buftype, OPT_LOCAL); + set_option_value((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL); + set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL); set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); RESET_BINDING(curwin); } -- cgit