Christian Brabandt wrote:
> On Di, 14 Okt 2014, Nikola Petrov wrote:
>
> > I found the following issue with vimdiff. I want to %diffput the left
> > hand side from vimdiff to the right hand side. This has the side effect
> > of adding 1 additional blank line which is a problem for the workflow I
> > am currently using vimdiff for. I can reproduce this with
> >
> > vimdiff -u NONE
> >
> > so it is not something related to my configuration.
>
> I only see this when diffing with an empty file and this seems to be
> fixed by
>
> diff --git a/src/diff.c b/src/diff.c
> --- a/src/diff.c
> +++ b/src/diff.c
> @@ -2327,7 +2327,7 @@ ex_diffgetput(eap)
>
> buf_empty = FALSE;
> added = 0;
> - for (i = 0; i < count; ++i)
> + for (i = 0; i <= count; ++i)
> {
> /* remember deleting the last line of the buffer */
> buf_empty = curbuf->b_ml.ml_line_count == 1;
That seems to be a bit too simple. Doesn't this break situations when
not using "%" for the range?
I would think the count needs to be incremented for an empty file, where
there is a single empty line. Setting buf_empty would also work.
Perhaps like this:
*** ../vim-7.4.476/src/diff.c 2014-05-28 11:35:33.424011248 +0200
--- src/diff.c 2014-10-15 12:51:51.566015316 +0200
***************
*** 2325,2331 ****
end_skip = 0;
}
! buf_empty = FALSE;
added = 0;
for (i = 0; i < count; ++i)
{
--- 2325,2331 ----
end_skip = 0;
}
! buf_empty = curbuf->b_ml.ml_line_count == 1;
added = 0;
for (i = 0; i < count; ++i)
{
Seems to work. But it's better to use bufempty(). I'll make a patch
for that.
--
GALAHAD: Camelot ...
LAUNCELOT: Camelot ...
GAWAIN: It's only a model.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.