summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-18 09:33:54 +0100
committerChristian Brabandt <cb@256bit.org>2024-02-18 09:33:54 +0100
commitfcaed6a70faf73bff3e5405ada556d726024f866 (patch)
tree5dae7674b1115ae5298940a54e54d9f97975b1d9
parent79230f027a25ff12eb7c7b64e1c063297876aae2 (diff)
patch 9.1.0114: Setting some options may change curswantv9.1.0114
Problem: Setting some options changes curswant unnecessarily. Solution: Add a P_HLONLY flag that prevents changing curswant. (zeertzjq) closes: #14044 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--src/option.c18
-rw-r--r--src/option.h6
-rw-r--r--src/optiondefs.h22
-rw-r--r--src/optionstr.c3
-rw-r--r--src/testdir/test_goto.vim13
-rw-r--r--src/version.c2
6 files changed, 40 insertions, 24 deletions
diff --git a/src/option.c b/src/option.c
index f0e77270a4..dd3542f895 100644
--- a/src/option.c
+++ b/src/option.c
@@ -4596,8 +4596,10 @@ set_bool_option(
#endif
comp_col(); // in case 'ruler' or 'showcmd' changed
+
if (curwin->w_curswant != MAXCOL
- && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
+ && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0
+ && (options[opt_idx].flags & P_HLONLY) == 0)
curwin->w_set_curswant = TRUE;
if ((opt_flags & OPT_NO_REDRAW) == 0)
@@ -4839,9 +4841,12 @@ set_num_option(
#endif
comp_col(); // in case 'columns' or 'ls' changed
+
if (curwin->w_curswant != MAXCOL
- && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
+ && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0
+ && (options[opt_idx].flags & P_HLONLY) == 0)
curwin->w_set_curswant = TRUE;
+
if ((opt_flags & OPT_NO_REDRAW) == 0)
check_redraw(options[opt_idx].flags);
@@ -4862,11 +4867,14 @@ check_redraw(long_u flags)
status_redraw_all();
if ((flags & P_RBUF) || (flags & P_RWIN) || all)
- changed_window_setting();
+ {
+ if (flags & P_HLONLY)
+ redraw_later(UPD_NOT_VALID);
+ else
+ changed_window_setting();
+ }
if (flags & P_RBUF)
redraw_curbuf_later(UPD_NOT_VALID);
- if (flags & P_RWINONLY)
- redraw_later(UPD_NOT_VALID);
if (doclear)
redraw_all_later(UPD_CLEAR);
else if (all)
diff --git a/src/option.h b/src/option.h
index 0cf6a8cf6d..28a4a96b41 100644
--- a/src/option.h
+++ b/src/option.h
@@ -38,8 +38,8 @@
#define P_RSTAT 0x1000 // redraw status lines
#define P_RWIN 0x2000 // redraw current window and recompute text
#define P_RBUF 0x4000 // redraw current buffer and recompute text
-#define P_RALL 0x6000 // redraw all windows
-#define P_RCLR 0x7000 // clear and redraw all
+#define P_RALL 0x6000 // redraw all windows and recompute text
+#define P_RCLR 0x7000 // clear and redraw all and recompute text
#define P_COMMA 0x8000 // comma separated list
#define P_ONECOMMA 0x18000L // P_COMMA and cannot have two consecutive
@@ -58,7 +58,7 @@
#define P_CURSWANT 0x4000000L // update curswant required; not needed when
// there is a redraw flag
#define P_NDNAME 0x8000000L // only normal dir name chars allowed
-#define P_RWINONLY 0x10000000L // only redraw current window
+#define P_HLONLY 0x10000000L // option only changes highlight, not text
#define P_MLE 0x20000000L // under control of 'modelineexpr'
#define P_FUNC 0x40000000L // accept a function reference or a lambda
#define P_COLON 0x80000000L // values use colons to create sublists
diff --git a/src/optiondefs.h b/src/optiondefs.h
index 5fa8f37e2b..776858804d 100644
--- a/src/optiondefs.h
+++ b/src/optiondefs.h
@@ -402,7 +402,7 @@ static struct vimoption options[] =
{"autowriteall","awa", P_BOOL|P_VI_DEF,
(char_u *)&p_awa, PV_NONE, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
- {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
+ {"background", "bg", P_STRING|P_VI_DEF|P_RCLR|P_HLONLY,
(char_u *)&p_bg, PV_NONE, did_set_background, expand_set_background,
{
#if (defined(MSWIN)) && !defined(FEAT_GUI)
@@ -609,7 +609,7 @@ static struct vimoption options[] =
{"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
(char_u *)&p_cwh, PV_NONE, NULL, NULL,
{(char_u *)7L, (char_u *)0L} SCTX_INIT},
- {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
+ {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN|P_HLONLY,
#ifdef FEAT_SYN_HL
(char_u *)VAR_WIN, PV_CC, did_set_colorcolumn, NULL,
#else
@@ -774,21 +774,21 @@ static struct vimoption options[] =
{"cursorbind", "crb", P_BOOL|P_VI_DEF,
(char_u *)VAR_WIN, PV_CRBIND, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
- {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWINONLY,
+ {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN|P_HLONLY,
#ifdef FEAT_SYN_HL
(char_u *)VAR_WIN, PV_CUC, NULL, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
- {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
+ {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN|P_HLONLY,
#ifdef FEAT_SYN_HL
(char_u *)VAR_WIN, PV_CUL, NULL, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
- {"cursorlineopt", "culopt", P_STRING|P_VI_DEF|P_RWIN|P_ONECOMMA|P_NODUP,
+ {"cursorlineopt", "culopt", P_STRING|P_VI_DEF|P_RWIN|P_HLONLY|P_ONECOMMA|P_NODUP,
#ifdef FEAT_SYN_HL
(char_u *)VAR_WIN, PV_CULOPT,
did_set_cursorlineopt, expand_set_cursorlineopt,
@@ -1304,7 +1304,7 @@ static struct vimoption options[] =
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
- {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
+ {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL|P_HLONLY,
#if defined(FEAT_SEARCH_EXTRA)
(char_u *)&p_hls, PV_NONE, did_set_hlsearch, NULL,
#else
@@ -2350,14 +2350,14 @@ static struct vimoption options[] =
{"sourceany", NULL, P_BOOL|P_VI_DEF,
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
- {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
+ {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_HLONLY,
#ifdef FEAT_SPELL
(char_u *)VAR_WIN, PV_SPELL, did_set_spell, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
- {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
+ {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_HLONLY,
#ifdef FEAT_SPELL
(char_u *)&p_spc, PV_SPC, did_set_spellcapcheck, NULL,
{(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
@@ -2377,7 +2377,7 @@ static struct vimoption options[] =
#endif
SCTX_INIT},
{"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
- |P_RBUF|P_EXPAND,
+ |P_RBUF|P_HLONLY|P_EXPAND,
#ifdef FEAT_SPELL
(char_u *)&p_spl, PV_SPL, did_set_spelllang, NULL,
{(char_u *)"en", (char_u *)0L}
@@ -2387,7 +2387,7 @@ static struct vimoption options[] =
#endif
SCTX_INIT},
{"spelloptions", "spo", P_STRING|P_ALLOCED|P_VI_DEF
- |P_ONECOMMA|P_NODUP|P_RBUF,
+ |P_ONECOMMA|P_NODUP|P_RBUF|P_HLONLY,
#ifdef FEAT_SPELL
(char_u *)&p_spo, PV_SPO, did_set_spelloptions, expand_set_spelloptions,
{(char_u *)"", (char_u *)0L}
@@ -2596,7 +2596,7 @@ static struct vimoption options[] =
(char_u *)FALSE,
#endif
(char_u *)0L} SCTX_INIT},
- {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
+ {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF|P_HLONLY,
(char_u *)&p_tw, PV_TW, did_set_textwidth, NULL,
{(char_u *)0L, (char_u *)0L} SCTX_INIT},
{"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
diff --git a/src/optionstr.c b/src/optionstr.c
index c049b3b6fc..8b000abbb4 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -4510,7 +4510,8 @@ did_set_string_option(
#endif
if (curwin->w_curswant != MAXCOL
- && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0)
+ && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0
+ && (get_option_flags(opt_idx) & P_HLONLY) == 0)
curwin->w_set_curswant = TRUE;
if ((opt_flags & OPT_NO_REDRAW) == 0)
diff --git a/src/testdir/test_goto.vim b/src/testdir/test_goto.vim
index 85c156ac7a..357a8d27c8 100644
--- a/src/testdir/test_goto.vim
+++ b/src/testdir/test_goto.vim
@@ -312,18 +312,23 @@ func Test_gd_string_only()
call XTest_goto_decl('gd', lines, 5, 10)
endfunc
-" Check that setting 'cursorline' does not change curswant
-func Test_cursorline_keep_col()
+" Check that setting some options does not change curswant
+func Test_set_options_keep_col()
new
call setline(1, ['long long long line', 'short line'])
normal ggfi
let pos = getcurpos()
normal j
- set cursorline
+ set invhlsearch spell spelllang=en,cjk spelloptions=camel textwidth=80
+ set cursorline cursorcolumn cursorlineopt=line colorcolumn=+1
+ set background=dark
+ set background=light
normal k
call assert_equal(pos, getcurpos())
bwipe!
- set nocursorline
+ set hlsearch& spell& spelllang& spelloptions& textwidth&
+ set cursorline& cursorcolumn& cursorlineopt& colorcolumn&
+ set background&
endfunc
func Test_gd_local_block()
diff --git a/src/version.c b/src/version.c
index 25fff8382d..bcb1d7c9cc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 114,
+/**/
113,
/**/
112,