Hello, > Patch 7.3.810 > Problem: 'relativenumber is reset unexpectedly. (François Ingelrest) > Solution: After an option was reset also reset the global value. Add a test. > (Christian Brabandt)
this bug I wanted to fix since a long time. See these problem reports for reference: http://groups.google.com/group/vim_dev/tree/browse_frm/month/2011-06/a31555949a630937#doc_704d17d6ef33a9cb http://groups.google.com/group/vim_dev/tree/browse_frm/month/2012-03/a6662e58cccb720e#doc_e373c950580fd7f0 However, this patch doesn't consider ":setlocal", which now clears the global value of the 'nu' or 'rnu' counterpart. Here is a patch for this and for doing it right for ":setglobal", both with a test. And an additional test for ":set" and its influence on the global value. diff -r 84cc49b2da4f src/option.c --- a/src/option.c Sat Feb 16 18:16:15 2013 +0100 +++ b/src/option.c Sun Feb 17 00:07:08 2013 +0100 @@ -7630,22 +7630,31 @@ } #endif - /* 'number', 'relativenumber' */ - else if ((int *)varp == &curwin->w_p_nu - || (int *)varp == &curwin->w_p_rnu) - { - /* If 'number' is set, reset 'relativenumber'. */ - /* If 'relativenumber' is set, reset 'number'. */ - if ((int *)varp == &curwin->w_p_nu && curwin->w_p_nu) - { - curwin->w_p_rnu = FALSE; + /* If 'number' is set, reset 'relativenumber'. */ + /* If 'relativenumber' is set, reset 'number'. */ + else if ((int *)varp == &curwin->w_p_nu && curwin->w_p_nu) + { + curwin->w_p_rnu = FALSE; + + /* Only reset the other global value if the own value is set globally. */ + if (((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)) curwin->w_allbuf_opt.wo_rnu = FALSE; - } - if ((int *)varp == &curwin->w_p_rnu && curwin->w_p_rnu) - { - curwin->w_p_nu = FALSE; + } + else if ((int *)varp == &curwin->w_p_rnu && curwin->w_p_rnu) + { + curwin->w_p_nu = FALSE; + + /* Only reset the other global value if the own value is set globally. */ + if (((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)) curwin->w_allbuf_opt.wo_nu = FALSE; - } + } + else if ((int *)varp == &curwin->w_allbuf_opt.wo_nu && curwin->w_allbuf_opt.wo_nu) + { + curwin->w_allbuf_opt.wo_rnu = FALSE; + } + else if ((int *)varp == &curwin->w_allbuf_opt.wo_rnu && curwin->w_allbuf_opt.wo_rnu) + { + curwin->w_allbuf_opt.wo_nu = FALSE; } else if ((int *)varp == &curbuf->b_p_ro) diff -r 84cc49b2da4f src/testdir/test89.in --- a/src/testdir/test89.in Sat Feb 16 18:16:15 2013 +0100 +++ b/src/testdir/test89.in Sun Feb 17 00:07:08 2013 +0100 @@ -10,6 +10,43 @@ :$put ='results:' :$put a :$put b +:" +:set nonu nornu +:setglobal nu +:setlocal rnu +:redir @c | setglobal nu? | redir END +:set nonu nornu +:setglobal rnu +:setlocal nu +:redir @d | setglobal rnu? | redir END +:$put =':setlocal must NOT reset the other global value' +:$put c +:$put d +:" +:set nonu nornu +:setglobal nu +:setglobal rnu +:redir @e | setglobal nu? | redir END +:set nonu nornu +:setglobal rnu +:setglobal nu +:redir @f | setglobal rnu? | redir END +:$put =':setglobal MUST reset the other global value' +:$put e +:$put f +:" +:set nonu nornu +:set nu +:set rnu +:redir @g | setglobal nu? | redir END +:set nonu nornu +:set rnu +:set nu +:redir @h | setglobal rnu? | redir END +:$put =':set MUST reset the other global value' +:$put g +:$put h +:" :/^results/,$w! test.out :q! ENDTEST diff -r 84cc49b2da4f src/testdir/test89.ok --- a/src/testdir/test89.ok Sat Feb 16 18:16:15 2013 +0100 +++ b/src/testdir/test89.ok Sun Feb 17 00:07:08 2013 +0100 @@ -5,3 +5,18 @@ nonumber relativenumber +:setlocal must NOT reset the other global value + + number + + relativenumber +:setglobal MUST reset the other global value + +nonumber + +norelativenumber +:set MUST reset the other global value + +nonumber + +norelativenumber -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
