summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-04-05 18:45:26 +0200
committerBram Moolenaar <Bram@vim.org>2018-04-05 18:45:26 +0200
commit4a69634b1b55e06c4bf7f05b54125b1669b1c363 (patch)
treef340ce45a20af981e2542dd4540c1457c77b9648
parent878c96d5b9416170dfd28a02cba0db683f91c220 (diff)
downloadvim-git-8.0.1662.tar.gz
patch 8.0.1662: showing dump diff doesn't mention both file namesv8.0.1662
Problem: Showing dump diff doesn't mention both file names. Solution: Add the file name in the separator line.
-rw-r--r--src/terminal.c67
-rw-r--r--src/version.c2
2 files changed, 64 insertions, 5 deletions
diff --git a/src/terminal.c b/src/terminal.c
index fd30c6512..86b86474e 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -41,7 +41,7 @@
* - Add a way to set the 16 ANSI colors, to be used for 'termguicolors' and in
* the GUI.
* - Win32: Make terminal used for :!cmd in the GUI work better. Allow for
- * redirection.
+ * redirection. Probably in call to channel_set_pipes().
* - implement term_setsize()
* - Copy text in the vterm to the Vim buffer once in a while, so that
* completion works.
@@ -3917,6 +3917,57 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
}
/*
+ * Return an allocated string with at least "text_width" "=" characters and
+ * "fname" inserted in the middle.
+ */
+ static char_u *
+get_separator(int text_width, char_u *fname)
+{
+ int width = MAX(text_width, curwin->w_width);
+ char_u *textline;
+ int fname_size;
+ char_u *p = fname;
+ int i;
+ int off;
+
+ textline = alloc(width + STRLEN(fname) + 1);
+ if (textline == NULL)
+ return NULL;
+
+ fname_size = vim_strsize(fname);
+ if (fname_size < width - 8)
+ {
+ /* enough room, don't use the full window width */
+ width = MAX(text_width, fname_size + 8);
+ }
+ else if (fname_size > width - 8)
+ {
+ /* full name doesn't fit, use only the tail */
+ p = gettail(fname);
+ fname_size = vim_strsize(p);
+ }
+ /* skip characters until the name fits */
+ while (fname_size > width - 8)
+ {
+ p += (*mb_ptr2len)(p);
+ fname_size = vim_strsize(p);
+ }
+
+ for (i = 0; i < (width - fname_size) / 2 - 1; ++i)
+ textline[i] = '=';
+ textline[i++] = ' ';
+
+ STRCPY(textline + i, p);
+ off = STRLEN(textline);
+ textline[off] = ' ';
+ for (i = 1; i < (width - fname_size) / 2; ++i)
+ textline[off + i] = '=';
+ textline[off + i] = NUL;
+
+ return textline;
+}
+
+/*
* Common for "term_dumpdiff()" and "term_dumpload()".
*/
static void
@@ -4013,16 +4064,19 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
term->tl_top_diff_rows = curbuf->b_ml.ml_line_count;
- textline = alloc(width + 1);
+ textline = get_separator(width, fname1);
if (textline == NULL)
goto theend;
- for (i = 0; i < width; ++i)
- textline[i] = '=';
- textline[width] = NUL;
if (add_empty_scrollback(term, &term->tl_default_color, 0) == OK)
ml_append(curbuf->b_ml.ml_line_count, textline, 0, FALSE);
+ vim_free(textline);
+
+ textline = get_separator(width, fname2);
+ if (textline == NULL)
+ goto theend;
if (add_empty_scrollback(term, &term->tl_default_color, 0) == OK)
ml_append(curbuf->b_ml.ml_line_count, textline, 0, FALSE);
+ textline[width] = NUL;
bot_lnum = curbuf->b_ml.ml_line_count;
width2 = read_dump_file(fd2, &cursor_pos2);
@@ -4143,6 +4197,9 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
}
term->tl_cols = width;
+
+ /* looks better without wrapping */
+ curwin->w_p_wrap = 0;
}
theend:
diff --git a/src/version.c b/src/version.c
index 87a326a74..4b9761f67 100644
--- a/src/version.c
+++ b/src/version.c
@@ -763,6 +763,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1662,
+/**/
1661,
/**/
1660,