[patch] bug in do put operation

47 views
Skip to first unread message

Christian Brabandt

unread,
Nov 14, 2014, 7:09:45 AM11/14/14
to vim...@vim.org
Bram,
a bug has been reported at stackoverflow:
http://stackoverflow.com/questions/26927016/vim-change-list-behaviour

This happens, because the lnum variable should be decremented before
changed_bytes in do_put() (it was incremented in the loop before).

This patch fixes it.

Best,
Christian
--
Beidl, der
Jemand, den man nicht zu einer Feier einladen möchte, aber leider
einzuladen verpflichtet ist.
-- Douglas Adams, John Lloyd, Sven Böttcher ("Der tiefere Sinn des Labenz")
visual_change_bug.diff

Christian Brabandt

unread,
Nov 14, 2014, 11:46:49 AM11/14/14
to vim...@vim.org
On Fr, 14 Nov 2014, Christian Brabandt wrote:

> Bram,
> a bug has been reported at stackoverflow:
> http://stackoverflow.com/questions/26927016/vim-change-list-behaviour
>
> This happens, because the lnum variable should be decremented before
> changed_bytes in do_put() (it was incremented in the loop before).
>
> This patch fixes it.

This patch is better:

diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -3831,6 +3831,9 @@ do_put(regname, dir, count, flags)
lnum++;
} while (VIsual_active && lnum <= curbuf->b_visual.vi_end.lnum);

+ if (VIsual_active) /* reset lnum to the last visual line */
+ lnum--;
+
curbuf->b_op_end = curwin->w_cursor;
/* For "CTRL-O p" in Insert mode, put cursor after last char */
if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))



Best,
Christian
--
Man empfindet es oft als ungerecht, daß Menschen, die Stroh im Kopf
haben, auch noch Geld wie Heu besitzen.
-- Gerhard Uhlenbruck

Bram Moolenaar

unread,
Nov 15, 2014, 1:52:37 PM11/15/14
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

> Bram,
> a bug has been reported at stackoverflow:
> http://stackoverflow.com/questions/26927016/vim-change-list-behaviour
>
> This happens, because the lnum variable should be decremented before
> changed_bytes in do_put() (it was incremented in the loop before).
>
> This patch fixes it.

Thanks, I'll put it in the todo list.


--
Compilation process failed successfully.

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages