forked from aniani/vim
patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Problem: When editing a buffer 'colorcolumn' may not work. Solution: Set the buffer before copying option values. Call check_colorcolumn() after copying window options.
This commit is contained in:
parent
03ac52fc02
commit
010ee9657a
20
src/buffer.c
20
src/buffer.c
@ -1738,22 +1738,22 @@ set_curbuf(buf_T *buf, int action)
|
||||
static void
|
||||
enter_buffer(buf_T *buf)
|
||||
{
|
||||
/* Copy buffer and window local option values. Not for a help buffer. */
|
||||
// Get the buffer in the current window.
|
||||
curwin->w_buffer = buf;
|
||||
curbuf = buf;
|
||||
++curbuf->b_nwindows;
|
||||
|
||||
// Copy buffer and window local option values. Not for a help buffer.
|
||||
buf_copy_options(buf, BCO_ENTER | BCO_NOHELP);
|
||||
if (!buf->b_help)
|
||||
get_winopts(buf);
|
||||
#ifdef FEAT_FOLDING
|
||||
else
|
||||
/* Remove all folds in the window. */
|
||||
// Remove all folds in the window.
|
||||
clearFolding(curwin);
|
||||
foldUpdateAll(curwin); /* update folds (later). */
|
||||
foldUpdateAll(curwin); // update folds (later).
|
||||
#endif
|
||||
|
||||
/* Get the buffer in the current window. */
|
||||
curwin->w_buffer = buf;
|
||||
curbuf = buf;
|
||||
++curbuf->b_nwindows;
|
||||
|
||||
#ifdef FEAT_DIFF
|
||||
if (curwin->w_p_diff)
|
||||
diff_buf_add(curbuf);
|
||||
@ -2980,9 +2980,7 @@ get_winopts(buf_T *buf)
|
||||
if (p_fdls >= 0)
|
||||
curwin->w_p_fdl = p_fdls;
|
||||
#endif
|
||||
#ifdef FEAT_SYN_HL
|
||||
check_colorcolumn(curwin);
|
||||
#endif
|
||||
after_copy_winopt(curwin);
|
||||
}
|
||||
|
||||
/*
|
||||
|
25
src/option.c
25
src/option.c
@ -2323,19 +2323,14 @@ didset_options(void)
|
||||
(void)did_set_spell_option(TRUE);
|
||||
#endif
|
||||
#ifdef FEAT_CMDWIN
|
||||
/* set cedit_key */
|
||||
// set cedit_key
|
||||
(void)check_cedit();
|
||||
#endif
|
||||
#ifdef FEAT_LINEBREAK
|
||||
briopt_check(curwin);
|
||||
#endif
|
||||
#ifdef FEAT_LINEBREAK
|
||||
/* initialize the table for 'breakat'. */
|
||||
fill_breakat_flags();
|
||||
#endif
|
||||
#ifdef FEAT_SYN_HL
|
||||
fill_culopt_flags(NULL, curwin);
|
||||
#endif
|
||||
after_copy_winopt(curwin);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5528,11 +5523,21 @@ win_copy_options(win_T *wp_from, win_T *wp_to)
|
||||
{
|
||||
copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
|
||||
copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
|
||||
#if defined(FEAT_LINEBREAK)
|
||||
briopt_check(wp_to);
|
||||
after_copy_winopt(wp_to);
|
||||
}
|
||||
|
||||
/*
|
||||
* After copying window options: update variables depending on options.
|
||||
*/
|
||||
void
|
||||
after_copy_winopt(win_T *wp)
|
||||
{
|
||||
#ifdef FEAT_LINEBREAK
|
||||
briopt_check(wp);
|
||||
#endif
|
||||
#ifdef FEAT_SYN_HL
|
||||
fill_culopt_flags(NULL, wp_to);
|
||||
fill_culopt_flags(NULL, wp);
|
||||
check_colorcolumn(wp);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -10,4 +10,17 @@ int get_lisp_indent(void);
|
||||
void do_c_expr_indent(void);
|
||||
void fixthisline(int (*get_the_indent)(void));
|
||||
void fix_indent(void);
|
||||
int tabstop_set(char_u *var, int **array);
|
||||
int tabstop_padding(colnr_T col, int ts_arg, int *vts);
|
||||
int tabstop_at(colnr_T col, int ts, int *vts);
|
||||
colnr_T tabstop_start(colnr_T col, int ts, int *vts);
|
||||
void tabstop_fromto(colnr_T start_col, colnr_T end_col, int ts_arg, int *vts, int *ntabs, int *nspcs);
|
||||
int tabstop_eq(int *ts1, int *ts2);
|
||||
int *tabstop_copy(int *oldts);
|
||||
int tabstop_count(int *ts);
|
||||
int tabstop_first(int *ts);
|
||||
long get_sw_value(buf_T *buf);
|
||||
long get_sw_value_indent(buf_T *buf);
|
||||
long get_sw_value_col(buf_T *buf, colnr_T col);
|
||||
long get_sts_value(void);
|
||||
/* vim: set ft=c : */
|
||||
|
@ -28,6 +28,7 @@ void check_redraw(long_u flags);
|
||||
int findoption(char_u *arg);
|
||||
int get_option_value(char_u *name, long *numval, char_u **stringval, int opt_flags);
|
||||
int get_option_value_strict(char_u *name, long *numval, char_u **stringval, int opt_type, void *from);
|
||||
char_u *option_iter_next(void **option, int opt_type);
|
||||
long_u get_option_flags(int opt_idx);
|
||||
void set_option_flag(int opt_idx, long_u flag);
|
||||
void clear_option_flag(int opt_idx, long_u flag);
|
||||
@ -36,7 +37,6 @@ int is_global_local_option(int opt_idx);
|
||||
int is_window_local_option(int opt_idx);
|
||||
int is_hidden_option(int opt_idx);
|
||||
int is_crypt_key_option(int opt_idx);
|
||||
char_u *option_iter_next(void **option, int opt_type);
|
||||
char *set_option_value(char_u *name, long number, char_u *string, int opt_flags);
|
||||
char_u *get_term_code(char_u *tname);
|
||||
char_u *get_highlight_default(void);
|
||||
@ -54,6 +54,7 @@ char_u *get_option_var(int opt_idx);
|
||||
char_u *get_option_fullname(int opt_idx);
|
||||
char_u *get_equalprg(void);
|
||||
void win_copy_options(win_T *wp_from, win_T *wp_to);
|
||||
void after_copy_winopt(win_T *wp);
|
||||
void copy_winopt(winopt_T *from, winopt_T *to);
|
||||
void clear_winopt(winopt_T *wop);
|
||||
void buf_copy_options(buf_T *buf, int flags);
|
||||
@ -74,19 +75,6 @@ int check_opt_wim(void);
|
||||
int can_bs(int what);
|
||||
void save_file_ff(buf_T *buf);
|
||||
int file_ff_differs(buf_T *buf, int ignore_empty);
|
||||
int tabstop_set(char_u *var, int **array);
|
||||
int tabstop_padding(colnr_T col, int ts_arg, int *vts);
|
||||
int tabstop_at(colnr_T col, int ts, int *vts);
|
||||
colnr_T tabstop_start(colnr_T col, int ts, int *vts);
|
||||
void tabstop_fromto(colnr_T start_col, colnr_T end_col, int ts_arg, int *vts, int *ntabs, int *nspcs);
|
||||
int tabstop_eq(int *ts1, int *ts2);
|
||||
int *tabstop_copy(int *oldts);
|
||||
int tabstop_count(int *ts);
|
||||
int tabstop_first(int *ts);
|
||||
long get_sw_value(buf_T *buf);
|
||||
long get_sw_value_indent(buf_T *buf);
|
||||
long get_sw_value_col(buf_T *buf, colnr_T col);
|
||||
long get_sts_value(void);
|
||||
long get_scrolloff_value(void);
|
||||
long get_sidescrolloff_value(void);
|
||||
void find_mps_values(int *initc, int *findc, int *backwards, int switchit);
|
||||
|
10
src/testdir/dumps/Test_colorcolumn_1.dump
Normal file
10
src/testdir/dumps/Test_colorcolumn_1.dump
Normal file
@ -0,0 +1,10 @@
|
||||
| +8#af5f00255#ffffff0@1|1| |1+0#0000000&@1|1+0&#ffd7d7255|1+0&#ffffff0@4|1+0&#ffd7d7255|1+0&#ffffff0| @60
|
||||
| +0#af5f00255&@1|2| |2+0#0000000&@1|2+0&#ffd7d7255|2+0&#ffffff0@4|2+0&#ffd7d7255|2+0&#ffffff0@1| @59
|
||||
| +0#af5f00255&@1|3| |3+0#0000000&@1|3+0&#ffd7d7255|3+0&#ffffff0@4|3+0&#ffd7d7255|3+0&#ffffff0| @60
|
||||
|~+0#4040ff13&| @73
|
||||
|X+1#0000000&| @55|1|,|1| @11|A|l@1
|
||||
| +8#af5f00255&@1|1| >1+0#0000000&@1|1+0&#ffd7d7255|1+0&#ffffff0@4|1+0&#ffd7d7255|1+0&#ffffff0| @60
|
||||
| +0#af5f00255&@1|2| |2+0#0000000&@1|2+0&#ffd7d7255|2+0&#ffffff0@4|2+0&#ffd7d7255|2+0&#ffffff0@1| @59
|
||||
| +0#af5f00255&@1|3| |3+0#0000000&@1|3+0&#ffd7d7255|3+0&#ffffff0@4|3+0&#ffd7d7255|3+0&#ffffff0| @60
|
||||
|X+3&&| @55|1|,|1| @11|A|l@1
|
||||
|:+0&&| @73
|
@ -618,6 +618,31 @@ func Test_wincolor()
|
||||
call delete('Xtest_wincolor')
|
||||
endfunc
|
||||
|
||||
func Test_colorcolumn()
|
||||
CheckScreendump
|
||||
|
||||
" check that setting 'colorcolumn' when entering a buffer works
|
||||
let lines =<< trim END
|
||||
split
|
||||
edit X
|
||||
call setline(1, ["1111111111","22222222222","3333333333"])
|
||||
set nomodified
|
||||
set colorcolumn=3,9
|
||||
set number cursorline cursorlineopt=number
|
||||
wincmd w
|
||||
buf X
|
||||
END
|
||||
call writefile(lines, 'Xtest_colorcolumn')
|
||||
let buf = RunVimInTerminal('-S Xtest_colorcolumn', {'rows': 10})
|
||||
call term_sendkeys(buf, ":\<CR>")
|
||||
call term_wait(buf)
|
||||
call VerifyScreenDump(buf, 'Test_colorcolumn_1', {})
|
||||
|
||||
" clean up
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('Xtest_colorcolumn')
|
||||
endfunc
|
||||
|
||||
" This test must come before the Test_cursorline test, as it appears this
|
||||
" defines the Normal highlighting group anyway.
|
||||
func Test_1_highlight_Normalgroup_exists()
|
||||
|
@ -757,6 +757,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2073,
|
||||
/**/
|
||||
2072,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user