vim-patch:9.1.1808: Option insecure flags not copied when splitting window

Problem:  Option insecure flags not copied when splitting window.
Solution: Move window-local insecure flags to winopt_T and copy them
          properly (zeertzjq).

closes: vim/vim#18434

b3740f4b00
This commit is contained in:
zeertzjq
2025-09-30 06:37:23 +08:00
parent ff564237d2
commit 42f1864b62
5 changed files with 149 additions and 15 deletions

View File

@@ -211,6 +211,18 @@ typedef struct {
OptInt wo_winbl;
#define w_p_winbl w_onebuf_opt.wo_winbl // 'winblend'
// A few options have local flags for kOptFlagInsecure.
uint32_t wo_wrap_flags; // flags for 'wrap'
#define w_p_wrap_flags w_onebuf_opt.wo_wrap_flags
uint32_t wo_stl_flags; // flags for 'statusline'
#define w_p_stl_flags w_onebuf_opt.wo_stl_flags
uint32_t wo_wbr_flags; // flags for 'winbar'
#define w_p_wbr_flags w_onebuf_opt.wo_wbr_flags
uint32_t wo_fde_flags; // flags for 'foldexpr'
#define w_p_fde_flags w_onebuf_opt.wo_fde_flags
uint32_t wo_fdt_flags; // flags for 'foldtext'
#define w_p_fdt_flags w_onebuf_opt.wo_fdt_flags
sctx_T wo_script_ctx[kWinOptCount]; // SCTXs for window-local options
#define w_p_script_ctx w_onebuf_opt.wo_script_ctx
} winopt_T;
@@ -1302,12 +1314,6 @@ struct window_S {
// transform a pointer to a "onebuf" option into a "allbuf" option
#define GLOBAL_WO(p) ((char *)(p) + sizeof(winopt_T))
// A few options have local flags for kOptFlagInsecure.
uint32_t w_p_wrap_flags; // flags for 'wrap'
uint32_t w_p_stl_flags; // flags for 'statusline'
uint32_t w_p_wbr_flags; // flags for 'winbar'
uint32_t w_p_fde_flags; // flags for 'foldexpr'
uint32_t w_p_fdt_flags; // flags for 'foldtext'
int *w_p_cc_cols; // array of columns to highlight or NULL
uint8_t w_p_culopt_flags; // flags for cursorline highlighting

View File

@@ -1668,6 +1668,18 @@ uint32_t *insecure_flag(win_T *const wp, OptIndex opt_idx, int opt_flags)
default:
break;
}
} else {
// For global value of window-local options, use flags in w_allbuf_opt.
switch (opt_idx) {
case kOptWrap:
return &wp->w_allbuf_opt.wo_wrap_flags;
case kOptFoldexpr:
return &wp->w_allbuf_opt.wo_fde_flags;
case kOptFoldtext:
return &wp->w_allbuf_opt.wo_fdt_flags;
default:
break;
}
}
// Nothing special, return global flags field.
return &options[opt_idx].flags;
@@ -4925,6 +4937,12 @@ void copy_winopt(winopt_T *from, winopt_T *to)
to->wo_winbl = from->wo_winbl;
to->wo_stc = copy_option_val(from->wo_stc);
to->wo_wrap_flags = from->wo_wrap_flags;
to->wo_stl_flags = from->wo_stl_flags;
to->wo_wbr_flags = from->wo_wbr_flags;
to->wo_fde_flags = from->wo_fde_flags;
to->wo_fdt_flags = from->wo_fdt_flags;
// Copy the script context so that we know were the value was last set.
memmove(to->wo_script_ctx, from->wo_script_ctx, sizeof(to->wo_script_ctx));
check_winopt(to); // don't want NULL pointers