Skip to content

Commit a2477fd

Browse files
committed
patch 8.0.0121
Problem: Setting 'cursorline' changes the curswant column. (Daniel Hahler) Solution: Add the P_RWINONLY flag. (closes #1297)
1 parent 5643db8 commit a2477fd

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/option.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@ struct vimoption
435435

436436
/* when option changed, what to display: */
437437
#define P_RSTAT 0x1000 /* redraw status lines */
438-
#define P_RWIN 0x2000 /* redraw current window */
439-
#define P_RBUF 0x4000 /* redraw current buffer */
438+
#define P_RWIN 0x2000 /* redraw current window and recompute text */
439+
#define P_RBUF 0x4000 /* redraw current buffer and recompute text */
440440
#define P_RALL 0x6000 /* redraw all windows */
441441
#define P_RCLR 0x7000 /* clear and redraw all */
442442

@@ -457,6 +457,7 @@ struct vimoption
457457
#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
458458
* there is a redraw flag */
459459
#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
460+
#define P_RWINONLY 0x10000000L /* only redraw current window */
460461

461462
#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
462463

@@ -967,7 +968,7 @@ static struct vimoption options[] =
967968
(char_u *)NULL, PV_NONE,
968969
#endif
969970
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
970-
{"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
971+
{"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
971972
#ifdef FEAT_SYN_HL
972973
(char_u *)VAR_WIN, PV_CUL,
973974
#else
@@ -9055,6 +9056,8 @@ check_redraw(long_u flags)
90559056
changed_window_setting();
90569057
if (flags & P_RBUF)
90579058
redraw_curbuf_later(NOT_VALID);
9059+
if (flags & P_RWINONLY)
9060+
redraw_later(NOT_VALID);
90589061
if (doclear)
90599062
redraw_all_later(CLEAR);
90609063
else if (all)

src/testdir/test_goto.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,18 @@ func Test_gd_string_only()
273273
\ ]
274274
call XTest_goto_decl('gd', lines, 5, 10)
275275
endfunc
276+
277+
" Check that setting 'cursorline' does not change curswant
278+
func Test_cursorline_keep_col()
279+
new
280+
call setline(1, ['long long long line', 'short line'])
281+
normal ggfi
282+
let pos = getcurpos()
283+
normal j
284+
set cursorline
285+
normal k
286+
call assert_equal(pos, getcurpos())
287+
bwipe!
288+
set nocursorline
289+
endfunc
290+

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
121,
767769
/**/
768770
120,
769771
/**/

0 commit comments

Comments
 (0)