# HG changeset patch # User Christian Brabandt # Date 1522947608 -7200 # Node ID 486ad9fd9038f2dbdd860031a50821fed34cff6f # Parent 0dcc9ad68a6faea32199d5a21094796fc4056b0c patch 8.0.1662: showing dump diff doesn't mention both file names commit https://github.com/vim/vim/commit/4a69634b1b55e06c4bf7f05b54125b1669b1c363 Author: Bram Moolenaar Date: Thu Apr 5 18:45:26 2018 +0200 patch 8.0.1662: showing dump diff doesn't mention both file names Problem: Showing dump diff doesn't mention both file names. Solution: Add the file name in the separator line. diff --git a/src/terminal.c b/src/terminal.c --- 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 *curso } /* + * 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 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 } term->tl_cols = width; + + /* looks better without wrapping */ + curwin->w_p_wrap = 0; } theend: diff --git a/src/version.c b/src/version.c --- 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,