]> granicus.if.org Git - vim/commitdiff
patch 8.2.4208: using setbufvar() may change the window title v8.2.4208
authorBram Moolenaar <Bram@vim.org>
Mon, 24 Jan 2022 20:00:55 +0000 (20:00 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 24 Jan 2022 20:00:55 +0000 (20:00 +0000)
Problem:    Using setbufvar() may change the window title.
Solution:   Do not redraw when creating the autocommand window. (closes #9613)

src/autocmd.c
src/testdir/test_functions.vim
src/version.c

index 37f2480a88972922ef2c72dcb56e3ae87c7ef08a..a10be9b9283c144920ce1dd60d7c024a9bf1768e 100644 (file)
@@ -1518,7 +1518,10 @@ aucmd_prepbuf(
        p_acd = FALSE;
 #endif
 
+       // no redrawing and don't set the window title
+       ++RedrawingDisabled;
        (void)win_split_ins(0, WSP_TOP, aucmd_win, 0);
+       --RedrawingDisabled;
        (void)win_comp_pos();   // recompute window positions
        p_ea = save_ea;
 #ifdef FEAT_AUTOCHDIR
index 156a75277ae5adb7e428f46b487369a3ab0f03d9..3f197ca3d3e89000e77ad1002cc6bbec1670c0f6 100644 (file)
@@ -1630,6 +1630,28 @@ func Test_setbufvar_options()
   bwipe!
 endfunc
 
+func Test_setbufvar_keep_window_title()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      edit Xa.txt
+      let g:buf = bufadd('Xb.txt')
+      inoremap <F2> <C-R>=setbufvar(g:buf, '&autoindent', 1) ?? ''<CR>
+  END
+  call writefile(lines, 'Xsetbufvar')
+  let buf = RunVimInTerminal('-S Xsetbufvar', {})
+  call assert_match('Xa.txt', term_gettitle(buf))
+
+  call term_sendkeys(buf, "i\<F2>")
+  call TermWait(buf)
+  call term_sendkeys(buf, "\<Esc>")
+  call TermWait(buf)
+  call assert_match('Xa.txt', term_gettitle(buf))
+
+  call StopVimInTerminal(buf)
+  call delete('Xsetbufvar')
+endfunc
+
 func Test_redo_in_nested_functions()
   nnoremap g. :set opfunc=Operator<CR>g@
   function Operator( type, ... )
@@ -2308,7 +2330,6 @@ endfunc
 
 func Test_state()
   CheckRunVimInTerminal
-  let g:test_is_flaky = 1
 
   let getstate = ":echo 'state: ' .. g:state .. '; mode: ' .. g:mode\<CR>"
 
index 6703e8fafe959bd273f96eab42260844ba3b3635..3b7cddd9f2987dd9ff0aade1ea7de499c0f5ad47 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4208,
 /**/
     4207,
 /**/