Problem: Vim9: sourcing Vim9 script triggers a redraw.
Solution: Do not let setting/restoring 'cpoptions' cause a redraw.
(closes #7920)
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);
+
+ if ((opt_flags & OPT_NO_REDRAW) == 0)
+ check_redraw(options[opt_idx].flags);
return NULL;
}
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
+ int opt_flags) // OPT_LOCAL, OPT_GLOBAL,
+ // OPT_MODELINE, etc.
{
char *errmsg = NULL;
long old_value = *(long *)varp;
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);
+ if ((opt_flags & OPT_NO_REDRAW) == 0)
+ check_redraw(options[opt_idx].flags);
return errmsg;
}
&& (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)
+ // 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));
+ check_redraw(get_option_flags(opt_idx));
+ }
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
if (did_swaptcap)
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);
+ set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, OPT_NO_REDRAW);
VIM_CLEAR(si->sn_save_cpo);
}
--- /dev/null
+|s+0&#ffffff0|o+0&#e0e0e08|m|e| |t|e|x|t| | +0&#ffffff0@64
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|'|<|,|'|>> @68
source view_util.vim
source vim9.vim
source shared.vim
+source screendump.vim
def Test_range_only()
new
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, "\<Esc>u")
+ StopVimInTerminal(buf)
+ delete('XTest_redraw_cpo')
+ delete('Xdir', 'rf')
+enddef
+
def Test_unset_any_variable()
var lines =<< trim END
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2581,
/**/
2580,
/**/
#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'
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);
+ 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.