changeset 17314:b60402471f69 v8.1.1656

patch 8.1.1656: popup window width is wrong when using Tabs commit https://github.com/vim/vim/commit/e089c3fd6937524a14d22baa7562b0820f1343ac Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 9 20:25:25 2019 +0200 patch 8.1.1656: popup window width is wrong when using Tabs Problem: Popup window width is wrong when using Tabs. (Paul Jolly) Solution: Count tabs correctly. (closes https://github.com/vim/vim/issues/4637)
author Bram Moolenaar <Bram@vim.org>
date Tue, 09 Jul 2019 20:30:04 +0200
parents 240ad667960f
children f96f99faf747
files src/popupwin.c src/testdir/dumps/Test_popupwin_11.dump src/testdir/test_popupwin.vim src/version.c
diffstat 4 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -880,7 +880,9 @@ popup_adjust_position(win_T *wp)
     wp->w_width = 1;
     for (lnum = wp->w_topline; lnum <= wp->w_buffer->b_ml.ml_line_count; ++lnum)
     {
-	int len = vim_strsize(ml_get_buf(wp->w_buffer, lnum, FALSE));
+	// count Tabs for what they are worth
+	int len = win_linetabsize(wp, ml_get_buf(wp->w_buffer, lnum, FALSE),
+							      (colnr_T)MAXCOL);
 
 	if (wp->w_p_wrap)
 	{
--- a/src/testdir/dumps/Test_popupwin_11.dump
+++ b/src/testdir/dumps/Test_popupwin_11.dump
@@ -1,10 +1,10 @@
 >1+0&#ffffff0| @73
 |2| @73
-|3| @18|#+0#e000e06#e0e0e08|i|n|c|l|u|d|e| |<+0#e000002&|s|t|d|i|o|.|h|>| +0#0000000#ffffff0@36
-|4| @18|i+0#00e0003#e0e0e08|n|t| +0#0000000&|m|a|i|n|(|v+0#00e0003&|o|i|d|)+0#0000000&| @3| +0&#ffffff0@36
-|5| @18|{+0&#e0e0e08| @16| +0&#ffffff0@36
-|6| @18| +0&#e0e0e08@3|p|r|i|n|t|f|(|5+0#e000002&|6|7|)+0#0000000&|;| @1| +0&#ffffff0@36
-|7| @18|}+0&#e0e0e08| @16| +0&#ffffff0@36
+|3| @18|#+0#e000e06#e0e0e08|i|n|c|l|u|d|e| |<+0#e000002&|s|t|d|i|o|.|h|>| +0#0000000&@1| +0&#ffffff0@34
+|4| @18|i+0#00e0003#e0e0e08|n|t| +0#0000000&|m|a|i|n|(|v+0#00e0003&|o|i|d|)+0#0000000&| @5| +0&#ffffff0@34
+|5| @18|{+0&#e0e0e08| @18| +0&#ffffff0@34
+|6| @18| +0&#e0e0e08@7|p|r|i|n|t|f|(|5+0#e000002&|6|7|)+0#0000000&|;| +0&#ffffff0@34
+|7| @18|}+0&#e0e0e08| @18| +0&#ffffff0@34
 |8| @73
 |9| @73
 @57|1|,|1| @10|T|o|p| 
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -225,7 +225,7 @@ func Test_popup_with_syntax_setbufvar()
 	    \ '#include <stdio.h>',
 	    \ 'int main(void)',
 	    \ '{',
-	    \ '    printf(567);',
+	    \ "\tprintf(567);",
 	    \ '}',
 	    \], {'line': 3, 'col': 21, 'highlight': 'PopupColor'})
 	call setbufvar(winbufnr(winid), '&syntax', 'cpp')
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1656,
+/**/
     1655,
 /**/
     1654,