To: vim_dev@googlegroups.com Subject: Patch 8.2.2581 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2581 Problem: Vim9: sourcing Vim9 script triggers a redraw. Solution: Do not let setting/restoring 'cpoptions' cause a redraw. (closes #7920) Files: src/vim.h, src/option.c, src/optionstr.c, src/scriptfile.c, src/vim9script.c, src/testdir/test_vim9_script.vim, src/testdir/dumps/Test_vim9_no_redraw.dump *** ../vim-8.2.2580/src/vim.h 2021-02-17 17:00:23.483706812 +0100 --- src/vim.h 2021-03-09 22:30:58.824750697 +0100 *************** *** 1200,1205 **** --- 1200,1206 ---- #define OPT_WINONLY 0x10 // only set window-local options #define OPT_NOWIN 0x20 // don't set window-local options #define OPT_ONECOLUMN 0x40 // list options one per line + #define OPT_NO_REDRAW 0x80 // ignore redraw flags on option // Magic chars used in confirm dialog strings #define DLG_BUTTON_SEP '\n' *** ../vim-8.2.2580/src/option.c 2021-02-15 20:37:58.457374538 +0100 --- src/option.c 2021-03-09 22:33:00.988400286 +0100 *************** *** 3176,3182 **** if (curwin->w_curswant != MAXCOL && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; ! check_redraw(options[opt_idx].flags); return NULL; } --- 3176,3184 ---- if (curwin->w_curswant != MAXCOL && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; ! ! if ((opt_flags & OPT_NO_REDRAW) == 0) ! check_redraw(options[opt_idx].flags); return NULL; } *************** *** 3192,3199 **** long value, // new value char *errbuf, // buffer for error messages size_t errbuflen, // length of "errbuf" ! int opt_flags) // OPT_LOCAL, OPT_GLOBAL and ! // OPT_MODELINE { char *errmsg = NULL; long old_value = *(long *)varp; --- 3194,3201 ---- long value, // new value char *errbuf, // buffer for error messages size_t errbuflen, // length of "errbuf" ! int opt_flags) // OPT_LOCAL, OPT_GLOBAL, ! // OPT_MODELINE, etc. { char *errmsg = NULL; long old_value = *(long *)varp; *************** *** 3734,3740 **** if (curwin->w_curswant != MAXCOL && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; ! check_redraw(options[opt_idx].flags); return errmsg; } --- 3736,3743 ---- if (curwin->w_curswant != MAXCOL && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; ! if ((opt_flags & OPT_NO_REDRAW) == 0) ! check_redraw(options[opt_idx].flags); return errmsg; } *** ../vim-8.2.2580/src/optionstr.c 2021-02-15 20:37:58.457374538 +0100 --- src/optionstr.c 2021-03-09 22:33:44.616275568 +0100 *************** *** 2461,2471 **** && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; #ifdef FEAT_GUI ! // check redraw when it's not a GUI option or the GUI is active. ! if (!redraw_gui_only || gui.in_use) #endif ! check_redraw(get_option_flags(opt_idx)); #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) if (did_swaptcap) --- 2461,2474 ---- && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; + if ((opt_flags & OPT_NO_REDRAW) == 0) + { #ifdef FEAT_GUI ! // check redraw when it's not a GUI option or the GUI is active. ! if (!redraw_gui_only || gui.in_use) #endif ! check_redraw(get_option_flags(opt_idx)); ! } #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) if (did_swaptcap) *** ../vim-8.2.2580/src/scriptfile.c 2021-02-07 17:17:54.739378027 +0100 --- src/scriptfile.c 2021-03-09 22:34:41.228114007 +0100 *************** *** 1459,1465 **** si = SCRIPT_ITEM(current_sctx.sc_sid); if (si->sn_save_cpo != NULL) { ! set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, 0); VIM_CLEAR(si->sn_save_cpo); } --- 1459,1465 ---- si = SCRIPT_ITEM(current_sctx.sc_sid); if (si->sn_save_cpo != NULL) { ! set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, OPT_NO_REDRAW); VIM_CLEAR(si->sn_save_cpo); } *** ../vim-8.2.2580/src/vim9script.c 2021-03-03 21:22:37.178739531 +0100 --- src/vim9script.c 2021-03-10 13:38:24.770590288 +0100 *************** *** 75,81 **** if (STRCMP(p_cpo, CPO_VIM) != 0) { si->sn_save_cpo = vim_strsave(p_cpo); ! set_option_value((char_u *)"cpo", 0L, (char_u *)CPO_VIM, 0); } #else // No check for this being the first command, it doesn't matter. --- 75,81 ---- if (STRCMP(p_cpo, CPO_VIM) != 0) { si->sn_save_cpo = vim_strsave(p_cpo); ! set_option_value((char_u *)"cpo", 0L, (char_u *)CPO_VIM, OPT_NO_REDRAW); } #else // No check for this being the first command, it doesn't matter. *** ../vim-8.2.2580/src/testdir/test_vim9_script.vim 2021-03-08 21:47:09.668648808 +0100 --- src/testdir/test_vim9_script.vim 2021-03-10 13:36:16.846970841 +0100 *************** *** 5,10 **** --- 5,11 ---- source view_util.vim source vim9.vim source shared.vim + source screendump.vim def Test_range_only() new *************** *** 3338,3343 **** --- 3339,3374 ---- set cpo&vim enddef + def Test_no_redraw_when_restoring_cpo() + CheckScreendump + + var lines =<< trim END + vim9script + def script#func() + enddef + END + mkdir('Xdir/autoload', 'p') + writefile(lines, 'Xdir/autoload/script.vim') + + lines =<< trim END + vim9script + set cpo+=M + exe 'set rtp^=' .. getcwd() .. '/Xdir' + au CmdlineEnter : ++once timer_start(0, () => script#func()) + setline(1, 'some text') + END + writefile(lines, 'XTest_redraw_cpo') + var buf = RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6}) + term_sendkeys(buf, "V:") + VerifyScreenDump(buf, 'Test_vim9_no_redraw', {}) + + # clean up + term_sendkeys(buf, "\u") + StopVimInTerminal(buf) + delete('XTest_redraw_cpo') + delete('Xdir', 'rf') + enddef + def Test_unset_any_variable() var lines =<< trim END *** ../vim-8.2.2580/src/testdir/dumps/Test_vim9_no_redraw.dump 2021-03-10 13:38:47.398523549 +0100 --- src/testdir/dumps/Test_vim9_no_redraw.dump 2021-03-10 13:36:26.470941982 +0100 *************** *** 0 **** --- 1,6 ---- + |s+0&#ffffff0|o+0&#e0e0e08|m|e| |t|e|x|t| | +0&#ffffff0@64 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |~| @73 + |:+0#0000000&|'|<|,|'|>> @68 *** ../vim-8.2.2580/src/version.c 2021-03-08 21:47:09.668648808 +0100 --- src/version.c 2021-03-09 22:35:37.987952326 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2581, /**/ -- ARTHUR: Old woman! DENNIS: Man! ARTHUR: Man. I'm sorry. Old man, What knight live in that castle over there? DENNIS: I'm thirty-seven. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///