changeset 17584:65a8099fc0e8 v8.1.1789

patch 8.1.1789: cannot see file name of preview popup window commit https://github.com/vim/vim/commit/90f3e7ac56056ffad50bac9d4497b5830c37ab26 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 1 22:40:44 2019 +0200 patch 8.1.1789: cannot see file name of preview popup window Problem: Cannot see file name of preview popup window. Solution: Add the file name as the title.
author Bram Moolenaar <Bram@vim.org>
date Thu, 01 Aug 2019 22:45:05 +0200
parents 231b482948de
children 31b9488e5eb3
files src/ex_cmds.c src/fileio.c src/popupwin.c src/proto/popupwin.pro src/testdir/dumps/Test_popupwin_previewpopup_1.dump src/testdir/dumps/Test_popupwin_previewpopup_2.dump src/testdir/dumps/Test_popupwin_previewpopup_3.dump src/testdir/dumps/Test_popupwin_previewpopup_4.dump src/testdir/dumps/Test_popupwin_previewpopup_5.dump src/version.c
diffstat 10 files changed, 66 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3172,6 +3172,10 @@ do_ecmd(
 #ifdef FEAT_TITLE
 	maketitle();
 #endif
+#ifdef FEAT_TEXT_PROP
+	if (popup_is_popup(curwin) && curwin->w_p_pvw)
+	    popup_set_title(curwin);
+#endif
     }
 
 #ifdef FEAT_DIFF
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6101,6 +6101,9 @@ shorten_fnames(int force)
     }
     status_redraw_all();
     redraw_tabline = TRUE;
+#ifdef FEAT_TEXT_PROP
+    popup_update_preview_title();
+#endif
 }
 
 #if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -3198,4 +3198,41 @@ popup_close_preview()
     }
 }
 
+/*
+ * Set the title of the popup window to the file name.
+ */
+    void
+popup_set_title(win_T *wp)
+{
+    if (wp->w_buffer->b_fname != NULL)
+    {
+	char_u	dirname[MAXPATHL];
+	size_t	len;
+
+	mch_dirname(dirname, MAXPATHL);
+	shorten_buf_fname(wp->w_buffer, dirname, FALSE);
+
+	vim_free(wp->w_popup_title);
+	len = STRLEN(wp->w_buffer->b_fname) + 3;
+	wp->w_popup_title = alloc((int)len);
+	if (wp->w_popup_title != NULL)
+	    vim_snprintf((char *)wp->w_popup_title, len, " %s ",
+							wp->w_buffer->b_fname);
+	redraw_win_later(wp, VALID);
+    }
+}
+
+/*
+ * If there is a preview window, update the title.
+ * Used after changing directory.
+ */
+    void
+popup_update_preview_title(void)
+{
+    win_T *wp = popup_find_preview_window();
+
+    if (wp != NULL)
+	popup_set_title(wp);
+}
+
 #endif // FEAT_TEXT_PROP
--- a/src/proto/popupwin.pro
+++ b/src/proto/popupwin.pro
@@ -47,4 +47,6 @@ void f_popup_getpreview(typval_T *argvar
 int popup_is_popup(win_T *wp);
 int popup_create_preview_window(void);
 void popup_close_preview(void);
+void popup_set_title(win_T *wp);
+void popup_update_preview_title(void);
 /* vim: set ft=c : */
--- a/src/testdir/dumps/Test_popupwin_previewpopup_1.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_1.dump
@@ -1,5 +1,5 @@
 |o+0&#ffffff0|n|e| @71
-|t|w|o| @1|╔+0#0000001#ffd7ff255|═@40|X| +0#0000000#ffffff0@26
+|t|w|o| @1|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@30|X| +0#0000000#ffffff0@26
 |t|h|r|e@1|║+0#0000001#ffd7ff255|2|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@26
 |f|o|u|r| |║+0#0000001#ffd7ff255|t|h|e|w|o|r|d| |i|s| |h|e|r|e| @24| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@26
 |f|i|v|e| |║+0#0000001#ffd7ff255|2@1| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@26
--- a/src/testdir/dumps/Test_popupwin_previewpopup_2.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_2.dump
@@ -1,7 +1,7 @@
 |o+0&#ffffff0|n|e| @71
 |t|w|o| @71
 |t|h|r|e@1| @69
-|f|o|u|r| @3|╔+0#0000001#ffd7ff255|═@40|X| +0#0000000#ffffff0@23
+|f|o|u|r| @3|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@30|X| +0#0000000#ffffff0@23
 |f|i|v|e| @3|║+0#0000001#ffd7ff255|2|7| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@23
 |s|i|x| @4|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@23
 |s|e|v|e|n| @2|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@23
--- a/src/testdir/dumps/Test_popupwin_previewpopup_3.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_3.dump
@@ -1,7 +1,7 @@
 |o+0&#ffffff0|n|e| @71
 |t|w|o| @71
 |t|h|r|e@1| @69
-|f|o|u|r| @9|╔+0#0000001#ffd7ff255|═@40|X| +0#0000000#ffffff0@17
+|f|o|u|r| @9|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@30|X| +0#0000000#ffffff0@17
 |f|i|v|e| @9|║+0#0000001#ffd7ff255|2|7| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
 |s|i|x| @10|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
 |s|e|v|e|n| @8|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
--- a/src/testdir/dumps/Test_popupwin_previewpopup_4.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_4.dump
@@ -2,7 +2,7 @@
 |t|w|o| @71
 |t|h|r|e@1| @69
 |f|o|u|r| @70
-|f|i|v|e| @27|╔+0#0000001#ffd7ff255|═@40|X
+|f|i|v|e| @27|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@30|X
 |s+0#0000000#ffffff0|i|x| @28|║+0#0000001#ffd7ff255|2|7| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
 |s+0#0000000#ffffff0|e|v|e|n| @26|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
 |f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @9|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_5.dump
@@ -0,0 +1,14 @@
+|o+0&#ffffff0|n|e| @71
+|t|w|o| @71
+|t|h|r|e@1| @69
+|f|o|u|r| @70
+|f|i|v|e| @27|╔+0#0000001#ffd7ff255| |t|e|s|t|d|i|r|/|X|t|a|g|f|i|l|e| |═@22|X
+|s+0#0000000#ffffff0|i|x| @28|║+0#0000001#ffd7ff255|2|7| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+|s+0#0000000#ffffff0|e|v|e|n| @26|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+|f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @9|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255
+|n+0#0000000#ffffff0|i|n|e| @27|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+|t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @11|╚+0#0000001#ffd7ff255|═@40|⇲
+|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
+|~+0#4040ff13&| @73
+|~| @73
+|:+0#0000000&| @55|1@1|,|3|9| @8|A|l@1| 
--- a/src/version.c
+++ b/src/version.c
@@ -774,6 +774,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1789,
+/**/
     1788,
 /**/
     1787,