mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.2.1307: popup window width does not include number of sign columns
Problem: popup window width does not include number, fold of sign column width. Solution: Take number, fold and sign column with into account.
This commit is contained in:
@@ -1111,6 +1111,7 @@ popup_adjust_position(win_T *wp)
|
|||||||
int wrapped = 0;
|
int wrapped = 0;
|
||||||
int maxwidth;
|
int maxwidth;
|
||||||
int used_maxwidth = FALSE;
|
int used_maxwidth = FALSE;
|
||||||
|
int margin_width = 0;
|
||||||
int maxspace;
|
int maxspace;
|
||||||
int center_vert = FALSE;
|
int center_vert = FALSE;
|
||||||
int center_hor = FALSE;
|
int center_hor = FALSE;
|
||||||
@@ -1249,6 +1250,19 @@ popup_adjust_position(win_T *wp)
|
|||||||
allow_adjust_left = FALSE;
|
allow_adjust_left = FALSE;
|
||||||
maxwidth = wp->w_maxwidth;
|
maxwidth = wp->w_maxwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wp->w_p_nu || wp->w_p_rnu)
|
||||||
|
margin_width = number_width(wp) + 1;
|
||||||
|
#ifdef FEAT_FOLDING
|
||||||
|
margin_width += wp->w_p_fdc;
|
||||||
|
#endif
|
||||||
|
#ifdef FEAT_SIGNS
|
||||||
|
if (signcolumn_on(wp))
|
||||||
|
margin_width += 2;
|
||||||
|
#endif
|
||||||
|
if (margin_width >= maxwidth)
|
||||||
|
margin_width = maxwidth - 1;
|
||||||
|
|
||||||
minwidth = wp->w_minwidth;
|
minwidth = wp->w_minwidth;
|
||||||
minheight = wp->w_minheight;
|
minheight = wp->w_minheight;
|
||||||
#ifdef FEAT_TERMINAL
|
#ifdef FEAT_TERMINAL
|
||||||
@@ -1289,6 +1303,7 @@ popup_adjust_position(win_T *wp)
|
|||||||
|
|
||||||
// Count Tabs for what they are worth and compute the length based on
|
// Count Tabs for what they are worth and compute the length based on
|
||||||
// the maximum width (matters when 'showbreak' is set).
|
// the maximum width (matters when 'showbreak' is set).
|
||||||
|
// "margin_width" is added to "len" where it matters.
|
||||||
if (wp->w_width < maxwidth)
|
if (wp->w_width < maxwidth)
|
||||||
wp->w_width = maxwidth;
|
wp->w_width = maxwidth;
|
||||||
len = win_linetabsize(wp, ml_get_buf(wp->w_buffer, lnum, FALSE),
|
len = win_linetabsize(wp, ml_get_buf(wp->w_buffer, lnum, FALSE),
|
||||||
@@ -1297,21 +1312,21 @@ popup_adjust_position(win_T *wp)
|
|||||||
|
|
||||||
if (wp->w_p_wrap)
|
if (wp->w_p_wrap)
|
||||||
{
|
{
|
||||||
while (len > maxwidth)
|
while (len + margin_width > maxwidth)
|
||||||
{
|
{
|
||||||
++wrapped;
|
++wrapped;
|
||||||
len -= maxwidth;
|
len -= maxwidth - margin_width;
|
||||||
wp->w_width = maxwidth;
|
wp->w_width = maxwidth;
|
||||||
used_maxwidth = TRUE;
|
used_maxwidth = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (len > maxwidth
|
else if (len + margin_width > maxwidth
|
||||||
&& allow_adjust_left
|
&& allow_adjust_left
|
||||||
&& (wp->w_popup_pos == POPPOS_TOPLEFT
|
&& (wp->w_popup_pos == POPPOS_TOPLEFT
|
||||||
|| wp->w_popup_pos == POPPOS_BOTLEFT))
|
|| wp->w_popup_pos == POPPOS_BOTLEFT))
|
||||||
{
|
{
|
||||||
// adjust leftwise to fit text on screen
|
// adjust leftwise to fit text on screen
|
||||||
int shift_by = len - maxwidth;
|
int shift_by = len + margin_width - maxwidth;
|
||||||
|
|
||||||
if (shift_by > wp->w_wincol)
|
if (shift_by > wp->w_wincol)
|
||||||
{
|
{
|
||||||
@@ -1325,9 +1340,9 @@ popup_adjust_position(win_T *wp)
|
|||||||
maxwidth += shift_by;
|
maxwidth += shift_by;
|
||||||
wp->w_width = maxwidth;
|
wp->w_width = maxwidth;
|
||||||
}
|
}
|
||||||
if (wp->w_width < len)
|
if (wp->w_width < len + margin_width)
|
||||||
{
|
{
|
||||||
wp->w_width = len;
|
wp->w_width = len + margin_width;
|
||||||
if (wp->w_maxwidth > 0 && wp->w_width > wp->w_maxwidth)
|
if (wp->w_maxwidth > 0 && wp->w_width > wp->w_maxwidth)
|
||||||
wp->w_width = wp->w_maxwidth;
|
wp->w_width = wp->w_maxwidth;
|
||||||
}
|
}
|
||||||
|
10
src/testdir/dumps/Test_popupwin_sign_2.dump
Normal file
10
src/testdir/dumps/Test_popupwin_sign_2.dump
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|>+0#e000002#ffffff0@1>0+0#ffffff16#ff404010| @71
|
||||||
|
| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0| @71
|
||||||
|
| +0#0000e05#a8a8a8255@1|2+0#0000000#ffffff0| @71
|
||||||
|
| +0#0000e05#a8a8a8255@1|3+0#0000000#ffffff0| @71
|
||||||
|
| +0#0000e05#a8a8a8255@1|4+0#0000000#ffffff0| @13| +0#0000e05#a8a8a8255@1|#+0#ffffff16#ff404010|!| +0#af5f00255#ffd7ff255@1|1| |a+0#0000001#ffff4012| |l|o|n|g|e|r| |l|i|n|e| |t|o| |c|h|e|c|k| |t|h|e| |w|i|d|t|h| +0#0000000#ffffff0@17
|
||||||
|
| +0#0000e05#a8a8a8255@1|5+0#0000000#ffffff0| @71
|
||||||
|
| +0#0000e05#a8a8a8255@1|6+0#0000000#ffffff0| @71
|
||||||
|
| +0#0000e05#a8a8a8255@1|7+0#0000000#ffffff0| @71
|
||||||
|
| +0#0000e05#a8a8a8255@1|8+0#0000000#ffffff0| @71
|
||||||
|
|:|c|a|l@1| |S|e|t|O|p|t|i|o|n|s|(|)| @38|1|,|1| @10|T|o|p|
|
@@ -3375,12 +3375,22 @@ func Test_popupwin_sign()
|
|||||||
call sign_place(3, 'PopUpSelected', 'Other', winbufnr, {'lnum': 1})
|
call sign_place(3, 'PopUpSelected', 'Other', winbufnr, {'lnum': 1})
|
||||||
" add sign to popup buffer, does not show
|
" add sign to popup buffer, does not show
|
||||||
call sign_place(4, 'Selected', 'Current', winbufnr, {'lnum': 2})
|
call sign_place(4, 'Selected', 'Current', winbufnr, {'lnum': 2})
|
||||||
|
|
||||||
|
func SetOptions()
|
||||||
|
call setwinvar(g:winid, '&number', 1)
|
||||||
|
call setwinvar(g:winid, '&foldcolumn', 2)
|
||||||
|
call popup_settext(g:winid, 'a longer line to check the width')
|
||||||
|
endfunc
|
||||||
END
|
END
|
||||||
call writefile(lines, 'XtestPopupSign')
|
call writefile(lines, 'XtestPopupSign')
|
||||||
|
|
||||||
let buf = RunVimInTerminal('-S XtestPopupSign', #{rows: 10})
|
let buf = RunVimInTerminal('-S XtestPopupSign', #{rows: 10})
|
||||||
call VerifyScreenDump(buf, 'Test_popupwin_sign_1', {})
|
call VerifyScreenDump(buf, 'Test_popupwin_sign_1', {})
|
||||||
|
|
||||||
|
" set more options to check the width is adjusted
|
||||||
|
call term_sendkeys(buf, ":call SetOptions()\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_popupwin_sign_2', {})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('XtestPopupSign')
|
call delete('XtestPopupSign')
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1307,
|
||||||
/**/
|
/**/
|
||||||
1306,
|
1306,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user