Mercurial > vim
comparison src/option.c @ 15713:ad8b2c109b22 v8.1.0864
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
commit https://github.com/vim/vim/commit/375e3390078e740d3c83b0c118c50d9a920036c7
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 31 18:26:10 2019 +0100
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Problem: Cannot have a local value for 'scrolloff' and 'sidescrolloff'.
(Gary Holloway)
Solution: Make 'scrolloff' and 'sidescrolloff' global-local. (mostly by
Aron Widforss, closes #3539)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 31 Jan 2019 18:30:08 +0100 |
parents | 9cd11f6beb70 |
children | a3e2e7948ee4 |
comparison
equal
deleted
inserted
replaced
15712:bc1989f9bd37 | 15713:ad8b2c109b22 |
---|---|
225 # define PV_RL OPT_WIN(WV_RL) | 225 # define PV_RL OPT_WIN(WV_RL) |
226 # define PV_RLC OPT_WIN(WV_RLC) | 226 # define PV_RLC OPT_WIN(WV_RLC) |
227 #endif | 227 #endif |
228 #define PV_SCBIND OPT_WIN(WV_SCBIND) | 228 #define PV_SCBIND OPT_WIN(WV_SCBIND) |
229 #define PV_SCROLL OPT_WIN(WV_SCROLL) | 229 #define PV_SCROLL OPT_WIN(WV_SCROLL) |
230 #define PV_SISO OPT_BOTH(OPT_WIN(WV_SISO)) | |
231 #define PV_SO OPT_BOTH(OPT_WIN(WV_SO)) | |
230 #ifdef FEAT_SPELL | 232 #ifdef FEAT_SPELL |
231 # define PV_SPELL OPT_WIN(WV_SPELL) | 233 # define PV_SPELL OPT_WIN(WV_SPELL) |
232 #endif | 234 #endif |
233 #ifdef FEAT_SYN_HL | 235 #ifdef FEAT_SYN_HL |
234 # define PV_CUC OPT_WIN(WV_CUC) | 236 # define PV_CUC OPT_WIN(WV_CUC) |
2331 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, | 2333 {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, |
2332 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM, | 2334 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM, |
2333 (char_u *)&p_sj, PV_NONE, | 2335 (char_u *)&p_sj, PV_NONE, |
2334 {(char_u *)1L, (char_u *)0L} SCTX_INIT}, | 2336 {(char_u *)1L, (char_u *)0L} SCTX_INIT}, |
2335 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL, | 2337 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL, |
2336 (char_u *)&p_so, PV_NONE, | 2338 (char_u *)&p_so, PV_SO, |
2337 {(char_u *)0L, (char_u *)0L} SCTX_INIT}, | 2339 {(char_u *)0L, (char_u *)0L} SCTX_INIT}, |
2338 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, | 2340 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, |
2339 (char_u *)&p_sbo, PV_NONE, | 2341 (char_u *)&p_sbo, PV_NONE, |
2340 {(char_u *)"ver,jump", (char_u *)0L} | 2342 {(char_u *)"ver,jump", (char_u *)0L} |
2341 SCTX_INIT}, | 2343 SCTX_INIT}, |
2488 {(char_u *)1L, (char_u *)0L} SCTX_INIT}, | 2490 {(char_u *)1L, (char_u *)0L} SCTX_INIT}, |
2489 {"sidescroll", "ss", P_NUM|P_VI_DEF, | 2491 {"sidescroll", "ss", P_NUM|P_VI_DEF, |
2490 (char_u *)&p_ss, PV_NONE, | 2492 (char_u *)&p_ss, PV_NONE, |
2491 {(char_u *)0L, (char_u *)0L} SCTX_INIT}, | 2493 {(char_u *)0L, (char_u *)0L} SCTX_INIT}, |
2492 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF, | 2494 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF, |
2493 (char_u *)&p_siso, PV_NONE, | 2495 (char_u *)&p_siso, PV_SISO, |
2494 {(char_u *)0L, (char_u *)0L} SCTX_INIT}, | 2496 {(char_u *)0L, (char_u *)0L} SCTX_INIT}, |
2495 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, | 2497 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, |
2496 #ifdef FEAT_SIGNS | 2498 #ifdef FEAT_SIGNS |
2497 (char_u *)VAR_WIN, PV_SCL, | 2499 (char_u *)VAR_WIN, PV_SCL, |
2498 {(char_u *)"auto", (char_u *)0L} | 2500 {(char_u *)"auto", (char_u *)0L} |
3734 { | 3736 { |
3735 if (options[opt_idx].indir == PV_SCROLL) | 3737 if (options[opt_idx].indir == PV_SCROLL) |
3736 win_comp_scroll(curwin); | 3738 win_comp_scroll(curwin); |
3737 else | 3739 else |
3738 { | 3740 { |
3739 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi]; | 3741 long def_val = (long)(long_i)options[opt_idx].def_val[dvi]; |
3742 | |
3743 if ((long *)varp == &curwin->w_p_so | |
3744 || (long *)varp == &curwin->w_p_siso) | |
3745 // 'scrolloff' and 'sidescrolloff' local values have a | |
3746 // different default value than the global default. | |
3747 *(long *)varp = -1; | |
3748 else | |
3749 *(long *)varp = def_val; | |
3740 /* May also set global value for local option. */ | 3750 /* May also set global value for local option. */ |
3741 if (both) | 3751 if (both) |
3742 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | 3752 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = |
3743 *(long *)varp; | 3753 def_val; |
3744 } | 3754 } |
3745 } | 3755 } |
3746 else /* P_BOOL */ | 3756 else /* P_BOOL */ |
3747 { | 3757 { |
3748 /* the cast to long is required for Manx C, long_i is needed for | 3758 /* the cast to long is required for Manx C, long_i is needed for |
9380 p_sj = 1; | 9390 p_sj = 1; |
9381 } | 9391 } |
9382 } | 9392 } |
9383 if (p_so < 0 && full_screen) | 9393 if (p_so < 0 && full_screen) |
9384 { | 9394 { |
9385 errmsg = e_scroll; | 9395 errmsg = e_positive; |
9386 p_so = 0; | 9396 p_so = 0; |
9387 } | 9397 } |
9388 if (p_siso < 0 && full_screen) | 9398 if (p_siso < 0 && full_screen) |
9389 { | 9399 { |
9390 errmsg = e_positive; | 9400 errmsg = e_positive; |
10655 break; | 10665 break; |
10656 case PV_TC: | 10666 case PV_TC: |
10657 clear_string_option(&buf->b_p_tc); | 10667 clear_string_option(&buf->b_p_tc); |
10658 buf->b_tc_flags = 0; | 10668 buf->b_tc_flags = 0; |
10659 break; | 10669 break; |
10670 case PV_SISO: | |
10671 curwin->w_p_siso = -1; | |
10672 break; | |
10673 case PV_SO: | |
10674 curwin->w_p_so = -1; | |
10675 break; | |
10660 #ifdef FEAT_FIND_ID | 10676 #ifdef FEAT_FIND_ID |
10661 case PV_DEF: | 10677 case PV_DEF: |
10662 clear_string_option(&buf->b_p_def); | 10678 clear_string_option(&buf->b_p_def); |
10663 break; | 10679 break; |
10664 case PV_INC: | 10680 case PV_INC: |
10743 case PV_KP: return (char_u *)&(curbuf->b_p_kp); | 10759 case PV_KP: return (char_u *)&(curbuf->b_p_kp); |
10744 case PV_PATH: return (char_u *)&(curbuf->b_p_path); | 10760 case PV_PATH: return (char_u *)&(curbuf->b_p_path); |
10745 case PV_AR: return (char_u *)&(curbuf->b_p_ar); | 10761 case PV_AR: return (char_u *)&(curbuf->b_p_ar); |
10746 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags); | 10762 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags); |
10747 case PV_TC: return (char_u *)&(curbuf->b_p_tc); | 10763 case PV_TC: return (char_u *)&(curbuf->b_p_tc); |
10764 case PV_SISO: return (char_u *)&(curwin->w_p_siso); | |
10765 case PV_SO: return (char_u *)&(curwin->w_p_so); | |
10748 #ifdef FEAT_FIND_ID | 10766 #ifdef FEAT_FIND_ID |
10749 case PV_DEF: return (char_u *)&(curbuf->b_p_def); | 10767 case PV_DEF: return (char_u *)&(curbuf->b_p_def); |
10750 case PV_INC: return (char_u *)&(curbuf->b_p_inc); | 10768 case PV_INC: return (char_u *)&(curbuf->b_p_inc); |
10751 #endif | 10769 #endif |
10752 #ifdef FEAT_INS_EXPAND | 10770 #ifdef FEAT_INS_EXPAND |
10801 ? (char_u *)&(curbuf->b_p_tags) : p->var; | 10819 ? (char_u *)&(curbuf->b_p_tags) : p->var; |
10802 case PV_TC: return *curbuf->b_p_tc != NUL | 10820 case PV_TC: return *curbuf->b_p_tc != NUL |
10803 ? (char_u *)&(curbuf->b_p_tc) : p->var; | 10821 ? (char_u *)&(curbuf->b_p_tc) : p->var; |
10804 case PV_BKC: return *curbuf->b_p_bkc != NUL | 10822 case PV_BKC: return *curbuf->b_p_bkc != NUL |
10805 ? (char_u *)&(curbuf->b_p_bkc) : p->var; | 10823 ? (char_u *)&(curbuf->b_p_bkc) : p->var; |
10824 case PV_SISO: return curwin->w_p_siso >= 0 | |
10825 ? (char_u *)&(curwin->w_p_siso) : p->var; | |
10826 case PV_SO: return curwin->w_p_so >= 0 | |
10827 ? (char_u *)&(curwin->w_p_so) : p->var; | |
10806 #ifdef FEAT_FIND_ID | 10828 #ifdef FEAT_FIND_ID |
10807 case PV_DEF: return *curbuf->b_p_def != NUL | 10829 case PV_DEF: return *curbuf->b_p_def != NUL |
10808 ? (char_u *)&(curbuf->b_p_def) : p->var; | 10830 ? (char_u *)&(curbuf->b_p_def) : p->var; |
10809 case PV_INC: return *curbuf->b_p_inc != NUL | 10831 case PV_INC: return *curbuf->b_p_inc != NUL |
10810 ? (char_u *)&(curbuf->b_p_inc) : p->var; | 10832 ? (char_u *)&(curbuf->b_p_inc) : p->var; |
13097 { | 13119 { |
13098 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts; | 13120 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts; |
13099 } | 13121 } |
13100 | 13122 |
13101 /* | 13123 /* |
13124 * Return the effective 'scrolloff' value for the current window, using the | |
13125 * global value when appropriate. | |
13126 */ | |
13127 long | |
13128 get_scrolloff_value(void) | |
13129 { | |
13130 return curwin->w_p_so < 0 ? p_so : curwin->w_p_so; | |
13131 } | |
13132 | |
13133 /* | |
13134 * Return the effective 'sidescrolloff' value for the current window, using the | |
13135 * global value when appropriate. | |
13136 */ | |
13137 long | |
13138 get_sidescrolloff_value(void) | |
13139 { | |
13140 return curwin->w_p_siso < 0 ? p_siso : curwin->w_p_siso; | |
13141 } | |
13142 | |
13143 /* | |
13102 * Check matchpairs option for "*initc". | 13144 * Check matchpairs option for "*initc". |
13103 * If there is a match set "*initc" to the matching character and "*findc" to | 13145 * If there is a match set "*initc" to the matching character and "*findc" to |
13104 * the opposite character. Set "*backwards" to the direction. | 13146 * the opposite character. Set "*backwards" to the direction. |
13105 * When "switchit" is TRUE swap the direction. | 13147 * When "switchit" is TRUE swap the direction. |
13106 */ | 13148 */ |