Skip to content

Commit 0263146

Browse files
committed
patch 8.0.1136: W_WIDTH() is always the same
Problem: W_WIDTH() is always the same. Solution: Expand the macro.
1 parent 53f8174 commit 0263146

26 files changed

+142
-142
lines changed

src/charset.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ win_lbr_chartabsize(
11001100
*/
11011101
numberextra = win_col_off(wp);
11021102
col2 = col;
1103-
colmax = (colnr_T)(W_WIDTH(wp) - numberextra - col_adj);
1103+
colmax = (colnr_T)(wp->w_width - numberextra - col_adj);
11041104
if (col >= colmax)
11051105
{
11061106
colmax += col_adj;
@@ -1151,10 +1151,10 @@ win_lbr_chartabsize(
11511151

11521152
numberextra = numberwidth;
11531153
col += numberextra + mb_added;
1154-
if (col >= (colnr_T)W_WIDTH(wp))
1154+
if (col >= (colnr_T)wp->w_width)
11551155
{
1156-
col -= W_WIDTH(wp);
1157-
numberextra = W_WIDTH(wp) - (numberextra - win_col_off2(wp));
1156+
col -= wp->w_width;
1157+
numberextra = wp->w_width - (numberextra - win_col_off2(wp));
11581158
if (col >= numberextra && numberextra > 0)
11591159
col %= numberextra;
11601160
if (*p_sbr != NUL)
@@ -1170,18 +1170,18 @@ win_lbr_chartabsize(
11701170

11711171
numberwidth -= win_col_off2(wp);
11721172
}
1173-
if (col == 0 || col + size + sbrlen > (colnr_T)W_WIDTH(wp))
1173+
if (col == 0 || col + size + sbrlen > (colnr_T)wp->w_width)
11741174
{
11751175
added = 0;
11761176
if (*p_sbr != NUL)
11771177
{
1178-
if (size + sbrlen + numberwidth > (colnr_T)W_WIDTH(wp))
1178+
if (size + sbrlen + numberwidth > (colnr_T)wp->w_width)
11791179
{
11801180
/* calculate effective window width */
1181-
int width = (colnr_T)W_WIDTH(wp) - sbrlen - numberwidth;
1182-
int prev_width = col ? ((colnr_T)W_WIDTH(wp) - (sbrlen + col)) : 0;
1181+
int width = (colnr_T)wp->w_width - sbrlen - numberwidth;
1182+
int prev_width = col ? ((colnr_T)wp->w_width - (sbrlen + col)) : 0;
11831183
if (width == 0)
1184-
width = (colnr_T)W_WIDTH(wp);
1184+
width = (colnr_T)wp->w_width;
11851185
added += ((size - prev_width) / width) * vim_strsize(p_sbr);
11861186
if ((size - prev_width) % width)
11871187
/* wrapped, add another length of 'sbr' */
@@ -1248,7 +1248,7 @@ in_win_border(win_T *wp, colnr_T vcol)
12481248

12491249
if (wp->w_width == 0) /* there is no border */
12501250
return FALSE;
1251-
width1 = W_WIDTH(wp) - win_col_off(wp);
1251+
width1 = wp->w_width - win_col_off(wp);
12521252
if ((int)vcol < width1 - 1)
12531253
return FALSE;
12541254
if ((int)vcol == width1 - 1)

src/edit.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ edit_putchar(int c, int highlight)
17831783
#ifdef FEAT_RIGHTLEFT
17841784
if (curwin->w_p_rl)
17851785
{
1786-
pc_col += W_WIDTH(curwin) - 1 - curwin->w_wcol;
1786+
pc_col += curwin->w_width - 1 - curwin->w_wcol;
17871787
# ifdef FEAT_MBYTE
17881788
if (has_mbyte)
17891789
{
@@ -1865,7 +1865,7 @@ display_dollar(colnr_T col)
18651865
}
18661866
#endif
18671867
curs_columns(FALSE); /* recompute w_wrow and w_wcol */
1868-
if (curwin->w_wcol < W_WIDTH(curwin))
1868+
if (curwin->w_wcol < curwin->w_width)
18691869
{
18701870
edit_putchar('$', FALSE);
18711871
dollar_vcol = curwin->w_virtcol;
@@ -6820,7 +6820,7 @@ check_auto_format(
68206820
/*
68216821
* Find out textwidth to be used for formatting:
68226822
* if 'textwidth' option is set, use it
6823-
* else if 'wrapmargin' option is set, use W_WIDTH(curwin) - 'wrapmargin'
6823+
* else if 'wrapmargin' option is set, use curwin->w_width - 'wrapmargin'
68246824
* if invalid value, use 0.
68256825
* Set default to window width (maximum 79) for "gq" operator.
68266826
*/
@@ -6835,7 +6835,7 @@ comp_textwidth(
68356835
{
68366836
/* The width is the window width minus 'wrapmargin' minus all the
68376837
* things that add to the margin. */
6838-
textwidth = W_WIDTH(curwin) - curbuf->b_p_wm;
6838+
textwidth = curwin->w_width - curbuf->b_p_wm;
68396839
#ifdef FEAT_CMDWIN
68406840
if (cmdwin_type != 0)
68416841
textwidth -= 1;
@@ -6854,7 +6854,7 @@ comp_textwidth(
68546854
textwidth = 0;
68556855
if (ff && textwidth == 0)
68566856
{
6857-
textwidth = W_WIDTH(curwin) - 1;
6857+
textwidth = curwin->w_width - 1;
68586858
if (textwidth > 79)
68596859
textwidth = 79;
68606860
}
@@ -9447,7 +9447,7 @@ ins_mousescroll(int dir)
94479447
int val, step = 6;
94489448

94499449
if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
9450-
step = W_WIDTH(curwin);
9450+
step = curwin->w_width;
94519451
val = curwin->w_leftcol + (dir == MSCR_RIGHT ? -step : step);
94529452
if (val < 0)
94539453
val = 0;

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13239,7 +13239,7 @@ f_winrestview(typval_T *argvars, typval_T *rettv UNUSED)
1323913239

1324013240
check_cursor();
1324113241
win_new_height(curwin, curwin->w_height);
13242-
win_new_width(curwin, W_WIDTH(curwin));
13242+
win_new_width(curwin, curwin->w_width);
1324313243
changed_window_setting();
1324413244

1324513245
if (curwin->w_topline <= 0)

src/ex_cmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ ex_align(exarg_T *eap)
177177
if (width <= 0)
178178
width = curbuf->b_p_tw;
179179
if (width == 0 && curbuf->b_p_wm > 0)
180-
width = W_WIDTH(curwin) - curbuf->b_p_wm;
180+
width = curwin->w_width - curbuf->b_p_wm;
181181
if (width <= 0)
182182
width = 80;
183183
}

src/ex_docmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8486,7 +8486,7 @@ ex_resize(exarg_T *eap)
84868486
if (cmdmod.split & WSP_VERT)
84878487
{
84888488
if (*eap->arg == '-' || *eap->arg == '+')
8489-
n += W_WIDTH(curwin);
8489+
n += curwin->w_width;
84908490
else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */
84918491
n = 9999;
84928492
win_setwidth_win((int)n, wp);

src/getchar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,8 +2666,8 @@ vgetorpeek(int advance)
26662666
++col;
26672667
}
26682668
curwin->w_wrow = curwin->w_cline_row
2669-
+ curwin->w_wcol / W_WIDTH(curwin);
2670-
curwin->w_wcol %= W_WIDTH(curwin);
2669+
+ curwin->w_wcol / curwin->w_width;
2670+
curwin->w_wcol %= curwin->w_width;
26712671
curwin->w_wcol += curwin_col_off();
26722672
#ifdef FEAT_MBYTE
26732673
col = 0; /* no correction needed */
@@ -2684,7 +2684,7 @@ vgetorpeek(int advance)
26842684
else if (curwin->w_p_wrap && curwin->w_wrow)
26852685
{
26862686
--curwin->w_wrow;
2687-
curwin->w_wcol = W_WIDTH(curwin) - 1;
2687+
curwin->w_wcol = curwin->w_width - 1;
26882688
#ifdef FEAT_MBYTE
26892689
col = curwin->w_cursor.col - 1;
26902690
#endif

src/gui.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4564,14 +4564,14 @@ gui_update_horiz_scrollbar(int force)
45644564
return;
45654565
}
45664566

4567-
size = W_WIDTH(curwin);
4567+
size = curwin->w_width;
45684568
if (curwin->w_p_wrap)
45694569
{
45704570
value = 0;
45714571
#ifdef SCROLL_PAST_END
45724572
max = 0;
45734573
#else
4574-
max = W_WIDTH(curwin) - 1;
4574+
max = curwin->w_width - 1;
45754575
#endif
45764576
}
45774577
else
@@ -4591,7 +4591,7 @@ gui_update_horiz_scrollbar(int force)
45914591
#endif
45924592

45934593
#ifndef SCROLL_PAST_END
4594-
max += W_WIDTH(curwin) - 1;
4594+
max += curwin->w_width - 1;
45954595
#endif
45964596
/* The line number isn't scrolled, thus there is less space when
45974597
* 'number' or 'relativenumber' is set (also for 'foldcolumn'). */

src/gui_beval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ get_beval_info(
338338
row = Y_2_ROW(beval->y);
339339
col = X_2_COL(beval->x);
340340
wp = mouse_find_win(&row, &col);
341-
if (wp != NULL && row < wp->w_height && col < W_WIDTH(wp))
341+
if (wp != NULL && row < wp->w_height && col < wp->w_width)
342342
{
343343
/* Found a window and the cursor is in the text. Now find the line
344344
* number. */

src/gui_mac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ gui_mac_scroll_action(ControlHandle theControl, short partCode)
16121612
else /* Bottom scrollbar */
16131613
{
16141614
sb_info = sb;
1615-
page = W_WIDTH(curwin) - 5;
1615+
page = curwin->w_width - 5;
16161616
}
16171617

16181618
switch (partCode)

src/if_lua.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ luaV_window_index(lua_State *L)
11791179
else if (strncmp(s, "col", 3) == 0)
11801180
lua_pushinteger(L, w->w_cursor.col + 1);
11811181
else if (strncmp(s, "width", 5) == 0)
1182-
lua_pushinteger(L, W_WIDTH(w));
1182+
lua_pushinteger(L, w->w_width);
11831183
else if (strncmp(s, "height", 6) == 0)
11841184
lua_pushinteger(L, w->w_height);
11851185
/* methods */

0 commit comments

Comments
 (0)