Bram,
if you reset the 'cp' option, the numberwidth value is not adjusted,
until you change a file. Consider this example from the vim source
directory:
vim -u NONE -c 'set nu' xpm_w32.h
Now do
:set numberwidth?
(outputs: 8)
:set nocp
:set numberwidth?
This will output 4, but note that the actual numberwidth is still 8 i.e.
the numbercolumn still is 8 chars wide and this will stay, until you add
or remove a line.
Here is a patch, that fixes this, by caching the numberwidth value and
make the number_width() function check, whether the 'numberwidth' option
value has changed.
Best,
Christian
--
An der guten Laune unserer Umgebung hängt unser Lebensglück.
-- Theodor Fontane
--
--
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/d/optout.
diff --git a/src/screen.c b/src/screen.c
--- a/src/screen.c
+++ b/src/screen.c
@@ -10718,7 +10718,7 @@ number_width(wp)
/* cursor line shows absolute line number */
lnum = wp->w_buffer->b_ml.ml_line_count;
- if (lnum == wp->w_nrwidth_line_count)
+ if (lnum == wp->w_nrwidth_line_count && wp->w_nuw_cached == wp->w_p_nuw)
return wp->w_nrwidth_width;
wp->w_nrwidth_line_count = lnum;
@@ -10734,6 +10734,7 @@ number_width(wp)
n = wp->w_p_nuw - 1;
wp->w_nrwidth_width = n;
+ wp->w_nuw_cached = wp->w_p_nuw;
return n;
}
#endif
diff --git a/src/structs.h b/src/structs.h
--- a/src/structs.h
+++ b/src/structs.h
@@ -2306,6 +2306,7 @@ struct window_S
#ifdef FEAT_LINEBREAK
linenr_T w_nrwidth_line_count; /* line count when ml_nrwidth_width
* was computed. */
+ long w_nuw_cached; /* 'numberwidth' option cached */
int w_nrwidth_width; /* nr of chars to print line count. */
#endif