forked from aniani/vim
		
	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.
This commit is contained in:
		| @@ -1127,7 +1127,7 @@ popup_adjust_position(win_T *wp) | |||||||
|     int		org_height = wp->w_height; |     int		org_height = wp->w_height; | ||||||
|     int		org_leftcol = wp->w_leftcol; |     int		org_leftcol = wp->w_leftcol; | ||||||
|     int		org_leftoff = wp->w_popup_leftoff; |     int		org_leftoff = wp->w_popup_leftoff; | ||||||
|     int		minwidth; |     int		minwidth, minheight; | ||||||
|     int		wantline = wp->w_wantline;  // adjusted for textprop |     int		wantline = wp->w_wantline;  // adjusted for textprop | ||||||
|     int		wantcol = wp->w_wantcol;    // adjusted for textprop |     int		wantcol = wp->w_wantcol;    // adjusted for textprop | ||||||
|     int		use_wantcol = wantcol != 0; |     int		use_wantcol = wantcol != 0; | ||||||
| @@ -1249,6 +1249,18 @@ popup_adjust_position(win_T *wp) | |||||||
| 	maxwidth = wp->w_maxwidth; | 	maxwidth = wp->w_maxwidth; | ||||||
|     } |     } | ||||||
|     minwidth = wp->w_minwidth; |     minwidth = wp->w_minwidth; | ||||||
|  |     minheight = wp->w_minheight; | ||||||
|  | #ifdef FEAT_TERMINAL | ||||||
|  |     // A terminal popup initially does not have content, use a default minimal | ||||||
|  |     // width of 20 characters and height of 5 lines. | ||||||
|  |     if (wp->w_buffer->b_term != NULL) | ||||||
|  |     { | ||||||
|  | 	if (minwidth == 0) | ||||||
|  | 	    minwidth = 20; | ||||||
|  | 	if (minheight == 0) | ||||||
|  | 	    minheight = 5; | ||||||
|  |     } | ||||||
|  | #endif | ||||||
|  |  | ||||||
|     // start at the desired first line |     // start at the desired first line | ||||||
|     if (wp->w_firstline > 0) |     if (wp->w_firstline > 0) | ||||||
| @@ -1419,8 +1431,8 @@ popup_adjust_position(win_T *wp) | |||||||
|  |  | ||||||
|     wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline |     wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline | ||||||
| 								 + 1 + wrapped; | 								 + 1 + wrapped; | ||||||
|     if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight) |     if (minheight > 0 && wp->w_height < minheight) | ||||||
| 	wp->w_height = wp->w_minheight; | 	wp->w_height = minheight; | ||||||
|     if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight) |     if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight) | ||||||
| 	wp->w_height = wp->w_maxheight; | 	wp->w_height = wp->w_maxheight; | ||||||
|     w_height_before_limit = wp->w_height; |     w_height_before_limit = wp->w_height; | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								src/testdir/dumps/Test_terminal_popup_m1.dump
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/testdir/dumps/Test_terminal_popup_m1.dump
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | |0+0&#ffffff0| @73 | ||||||
|  | |1| @73 | ||||||
|  | |2| @73 | ||||||
|  | |3| @73 | ||||||
|  | |4| @24|╔+0#0000001#ffd7ff255|═@19|╗| +0#0000000#ffffff0@26 | ||||||
|  | |5| @24|║+0#0000001#ffd7ff255|a|n|o|t|h|e|r| |t|e|x|t| @7|║| +0#0000000#ffffff0@26 | ||||||
|  | |6| @24|║+0#0000001#ffd7ff255|t|o| |s|h|o|w| @12|║| +0#0000000#ffffff0@26 | ||||||
|  | |7| @24|║+0#0000001#ffd7ff255|i|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @2|║| +0#0000000#ffffff0@26 | ||||||
|  | |8| @24|║+0#0000001#ffd7ff255| +0#4040ff13&> @18|║+0#0000001&| +0#0000000#ffffff0@26 | ||||||
|  | |9| @24|║+0#0000001#ffd7ff255| +0#4040ff13&@19|║+0#0000001&| +0#0000000#ffffff0@26 | ||||||
|  | |1|0| @23|╚+0#0000001#ffd7ff255|═@19|╝| +0#0000000#ffffff0@26 | ||||||
|  | |1@1| @72 | ||||||
|  | |1|2| @72 | ||||||
|  | |1|3| @72 | ||||||
|  | |:| @55|1|,|1| @10|T|o|p|  | ||||||
| @@ -2400,6 +2400,43 @@ func Test_terminal_in_popup() | |||||||
|   call term_wait(buf, 100)  " wait for terminal to vanish |   call term_wait(buf, 100)  " wait for terminal to vanish | ||||||
|  |  | ||||||
|   call StopVimInTerminal(buf) |   call StopVimInTerminal(buf) | ||||||
|  |   call delete('Xtext') | ||||||
|  |   call delete('XtermPopup') | ||||||
|  | endfunc | ||||||
|  |  | ||||||
|  | " Check a terminal in popup window uses the default mininum size. | ||||||
|  | func Test_terminal_in_popup_min_size() | ||||||
|  |   CheckRunVimInTerminal | ||||||
|  |  | ||||||
|  |   let text =<< trim END | ||||||
|  |     another text | ||||||
|  |     to show | ||||||
|  |     in a popup window | ||||||
|  |   END | ||||||
|  |   call writefile(text, 'Xtext') | ||||||
|  |   let lines = [ | ||||||
|  | 	\ 'set t_u7=', | ||||||
|  | 	\ 'call setline(1, range(20))', | ||||||
|  | 	\ 'hi PopTerm ctermbg=grey', | ||||||
|  | 	\ 'func OpenTerm()', | ||||||
|  | 	\ "  let s:buf = term_start('cat Xtext', #{hidden: 1})", | ||||||
|  | 	\ '  let g:winid = popup_create(s:buf, #{ border: []})', | ||||||
|  | 	\ 'endfunc', | ||||||
|  | 	\ ] | ||||||
|  |   call writefile(lines, 'XtermPopup') | ||||||
|  |   let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15}) | ||||||
|  |   call term_wait(buf, 100) | ||||||
|  |   call term_sendkeys(buf, "\<C-L>") | ||||||
|  |   call term_sendkeys(buf, ":call OpenTerm()\<CR>") | ||||||
|  |   call term_wait(buf, 100) | ||||||
|  |   call term_sendkeys(buf, ":\<CR>") | ||||||
|  |   call VerifyScreenDump(buf, 'Test_terminal_popup_m1', {}) | ||||||
|  |  | ||||||
|  |   call term_wait(buf, 100) | ||||||
|  |   call term_sendkeys(buf, ":q\<CR>") | ||||||
|  |   call term_wait(buf, 100)  " wait for terminal to vanish | ||||||
|  |   call StopVimInTerminal(buf) | ||||||
|  |   call delete('Xtext') | ||||||
|   call delete('XtermPopup') |   call delete('XtermPopup') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|   | |||||||
| @@ -738,6 +738,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 */ | ||||||
|  | /**/ | ||||||
|  |     380, | ||||||
| /**/ | /**/ | ||||||
|     379, |     379, | ||||||
| /**/ | /**/ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user