changeset 4736:3f2319a953b3 v7.3.1115

updated for version 7.3.1115 Problem: Many users don't like the cursor line number when 'relativenumber' is set. Solution: Have four combinations with 'number' and 'relativenumber'. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Tue, 04 Jun 2013 22:13:50 +0200
parents 4bdece3fb6a6
children c4bb9860b91e
files src/option.c src/screen.c src/testdir/test89.in src/testdir/test89.ok src/version.c
diffstat 5 files changed, 26 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/src/option.c
+++ b/src/option.c
@@ -7647,35 +7647,6 @@ set_bool_option(opt_idx, varp, value, op
     }
 #endif
 
-    /* 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 global value if the own value is set globally. */
-	if (((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0))
-	    curwin->w_allbuf_opt.wo_rnu = FALSE;
-    }
-    else if ((int *)varp == &curwin->w_p_rnu && curwin->w_p_rnu)
-    {
-	curwin->w_p_nu = FALSE;
-
-	/* Only reset the 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)
     {
 	/* when 'readonly' is reset globally, also reset readonlymode */
--- a/src/screen.c
+++ b/src/screen.c
@@ -2329,15 +2329,17 @@ fold_line(wp, fold_count, foldinfo, lnum
 	    if (len > w + 1)
 		len = w + 1;
 
-	    if (wp->w_p_nu)
-		/* 'number' */
+	    if (wp->w_p_nu && !wp->w_p_rnu)
+		/* 'number' + 'norelativenumber' */
 		num = (long)lnum;
 	    else
 	    {
 		/* 'relativenumber', don't use negative numbers */
 		num = labs((long)get_cursor_rel_lnum(wp, lnum));
-		if (num == 0)
-		{
+		if (num == 0 && wp->w_p_nu && wp->w_p_rnu)
+		{
+		    /* 'number' + 'relativenumber': cursor line shows absolute
+		     * line number */
 		    num = lnum;
 		    fmt = "%-*ld ";
 		}
@@ -3499,15 +3501,16 @@ win_line(wp, lnum, startrow, endrow, noc
 			long num;
 			char *fmt = "%*ld ";
 
-			if (wp->w_p_nu)
-			    /* 'number' */
+			if (wp->w_p_nu && !wp->w_p_rnu)
+			    /* 'number' + 'norelativenumber' */
 			    num = (long)lnum;
 			else
 			{
 			    /* 'relativenumber', don't use negative numbers */
 			    num = labs((long)get_cursor_rel_lnum(wp, lnum));
-			    if (num == 0)
+			    if (num == 0 && wp->w_p_nu && wp->w_p_rnu)
 			    {
+				/* 'number' + 'relativenumber' */
 				num = lnum;
 				fmt = "%-*ld ";
 			    }
@@ -10260,7 +10263,12 @@ number_width(wp)
     int		n;
     linenr_T	lnum;
 
-    lnum = wp->w_buffer->b_ml.ml_line_count;
+    if (wp->w_p_rnu && !wp->w_p_nu)
+	/* cursor line shows "0" */
+	lnum = wp->w_height;
+    else
+	/* cursor line shows absolute line number */
+	lnum = wp->w_buffer->b_ml.ml_line_count;
 
     if (lnum == wp->w_nrwidth_line_count)
 	return wp->w_nrwidth_width;
--- a/src/testdir/test89.in
+++ b/src/testdir/test89.in
@@ -1,4 +1,6 @@
 Some tests for setting 'number' and 'relativenumber'
+This is not all that useful now that the options are no longer reset when
+setting the other.
 
 STARTTEST
 :so small.vim
--- a/src/testdir/test89.ok
+++ b/src/testdir/test89.ok
@@ -1,9 +1,9 @@
 results:
 
-nonumber
+  number
   relativenumber
 
-nonumber
+  number
   relativenumber
 :setlocal must NOT reset the other global value
 
@@ -12,11 +12,11 @@ nonumber
   relativenumber
 :setglobal MUST reset the other global value
 
-nonumber
+  number
 
-norelativenumber
+  relativenumber
 :set MUST reset the other global value
 
-nonumber
+  number
 
-norelativenumber
+  relativenumber
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1115,
+/**/
     1114,
 /**/
     1113,