summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2013-06-04 22:13:50 +0200
committerBram Moolenaar <bram@vim.org>2013-06-04 22:13:50 +0200
commit5aec48683d27942700fe1be40249024411ae2737 (patch)
tree7853b677857603be21e0a178ad1f5a78f7f54089
parent260ea93192b530b62f7a794a4455eea989ac767c (diff)
downloadvim-5aec48683d27942700fe1be40249024411ae2737.tar.gz
updated for version 7.3.1115v7.3.1115v7-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)
-rw-r--r--src/option.c29
-rw-r--r--src/screen.c22
-rw-r--r--src/testdir/test89.in2
-rw-r--r--src/testdir/test89.ok12
-rw-r--r--src/version.c2
5 files changed, 25 insertions, 42 deletions
diff --git a/src/option.c b/src/option.c
index a9ee0673..fa28e840 100644
--- a/src/option.c
+++ b/src/option.c
@@ -7647,35 +7647,6 @@ set_bool_option(opt_idx, varp, value, opt_flags)
}
#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 */
diff --git a/src/screen.c b/src/screen.c
index cc8afa6d..cf6ed730 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -2329,15 +2329,17 @@ fold_line(wp, fold_count, foldinfo, lnum, row)
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, nochange)
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;
diff --git a/src/testdir/test89.in b/src/testdir/test89.in
index 4306edda..8e53c917 100644
--- 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
diff --git a/src/testdir/test89.ok b/src/testdir/test89.ok
index 93824bb9..17bb5d76 100644
--- 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
diff --git a/src/version.c b/src/version.c
index a2d70370..cf536b8d 100644
--- 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,