Skip to content

Commit 1939826

Browse files
committed
patch 8.2.0380: tiny popup when creating a terminal popup without minwidth
Problem: Tiny popup when creating a terminal popup without minwidth. Solution: Use a default mininum size of 5 lines of 20 characters.
1 parent b17893a commit 1939826

4 files changed

Lines changed: 69 additions & 3 deletions

File tree

src/popupwin.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ popup_adjust_position(win_T *wp)
11271127
int org_height = wp->w_height;
11281128
int org_leftcol = wp->w_leftcol;
11291129
int org_leftoff = wp->w_popup_leftoff;
1130-
int minwidth;
1130+
int minwidth, minheight;
11311131
int wantline = wp->w_wantline; // adjusted for textprop
11321132
int wantcol = wp->w_wantcol; // adjusted for textprop
11331133
int use_wantcol = wantcol != 0;
@@ -1249,6 +1249,18 @@ popup_adjust_position(win_T *wp)
12491249
maxwidth = wp->w_maxwidth;
12501250
}
12511251
minwidth = wp->w_minwidth;
1252+
minheight = wp->w_minheight;
1253+
#ifdef FEAT_TERMINAL
1254+
// A terminal popup initially does not have content, use a default minimal
1255+
// width of 20 characters and height of 5 lines.
1256+
if (wp->w_buffer->b_term != NULL)
1257+
{
1258+
if (minwidth == 0)
1259+
minwidth = 20;
1260+
if (minheight == 0)
1261+
minheight = 5;
1262+
}
1263+
#endif
12521264

12531265
// start at the desired first line
12541266
if (wp->w_firstline > 0)
@@ -1419,8 +1431,8 @@ popup_adjust_position(win_T *wp)
14191431

14201432
wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline
14211433
+ 1 + wrapped;
1422-
if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight)
1423-
wp->w_height = wp->w_minheight;
1434+
if (minheight > 0 && wp->w_height < minheight)
1435+
wp->w_height = minheight;
14241436
if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight)
14251437
wp->w_height = wp->w_maxheight;
14261438
w_height_before_limit = wp->w_height;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
|0+0&#ffffff0| @73
2+
|1| @73
3+
|2| @73
4+
|3| @73
5+
|4| @24|╔+0#0000001#ffd7ff255|═@19|╗| +0#0000000#ffffff0@26
6+
|5| @24|║+0#0000001#ffd7ff255|a|n|o|t|h|e|r| |t|e|x|t| @7|║| +0#0000000#ffffff0@26
7+
|6| @24|║+0#0000001#ffd7ff255|t|o| |s|h|o|w| @12|║| +0#0000000#ffffff0@26
8+
|7| @24|║+0#0000001#ffd7ff255|i|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @2|║| +0#0000000#ffffff0@26
9+
|8| @24|║+0#0000001#ffd7ff255| +0#4040ff13&> @18|║+0#0000001&| +0#0000000#ffffff0@26
10+
|9| @24|║+0#0000001#ffd7ff255| +0#4040ff13&@19|║+0#0000001&| +0#0000000#ffffff0@26
11+
|1|0| @23|╚+0#0000001#ffd7ff255|═@19|╝| +0#0000000#ffffff0@26
12+
|1@1| @72
13+
|1|2| @72
14+
|1|3| @72
15+
|:| @55|1|,|1| @10|T|o|p|

src/testdir/test_terminal.vim

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,6 +2400,43 @@ func Test_terminal_in_popup()
24002400
call term_wait(buf, 100) " wait for terminal to vanish
24012401

24022402
call StopVimInTerminal(buf)
2403+
call delete('Xtext')
2404+
call delete('XtermPopup')
2405+
endfunc
2406+
2407+
" Check a terminal in popup window uses the default mininum size.
2408+
func Test_terminal_in_popup_min_size()
2409+
CheckRunVimInTerminal
2410+
2411+
let text =<< trim END
2412+
another text
2413+
to show
2414+
in a popup window
2415+
END
2416+
call writefile(text, 'Xtext')
2417+
let lines = [
2418+
\ 'set t_u7=',
2419+
\ 'call setline(1, range(20))',
2420+
\ 'hi PopTerm ctermbg=grey',
2421+
\ 'func OpenTerm()',
2422+
\ " let s:buf = term_start('cat Xtext', #{hidden: 1})",
2423+
\ ' let g:winid = popup_create(s:buf, #{ border: []})',
2424+
\ 'endfunc',
2425+
\ ]
2426+
call writefile(lines, 'XtermPopup')
2427+
let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
2428+
call term_wait(buf, 100)
2429+
call term_sendkeys(buf, "\<C-L>")
2430+
call term_sendkeys(buf, ":call OpenTerm()\<CR>")
2431+
call term_wait(buf, 100)
2432+
call term_sendkeys(buf, ":\<CR>")
2433+
call VerifyScreenDump(buf, 'Test_terminal_popup_m1', {})
2434+
2435+
call term_wait(buf, 100)
2436+
call term_sendkeys(buf, ":q\<CR>")
2437+
call term_wait(buf, 100) " wait for terminal to vanish
2438+
call StopVimInTerminal(buf)
2439+
call delete('Xtext')
24032440
call delete('XtermPopup')
24042441
endfunc
24052442

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
380,
741743
/**/
742744
379,
743745
/**/

0 commit comments

Comments
 (0)