From 4e713bafc0ae191b1830e3cd3c323ebd695bc3a1 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 7 Feb 2022 15:31:37 +0000 Subject: patch 8.2.4319: :put does not work properly in compiled function Problem: :put does not work properly in compiled function. (John Beckett) Solution: Adjust the direction when using line zero. --- src/testdir/test_vim9_cmd.vim | 6 ++++++ src/version.c | 2 ++ src/vim9execute.c | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index 51a62e01f..0ac69e84f 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -1156,7 +1156,13 @@ def Test_put_command() :2put =['a', 'b', 'c'] assert_equal(['ppp', 'a', 'b', 'c', 'above'], getline(2, 6)) + :0put ='first' + assert_equal('first', getline(1)) + :1put! ='first again' + assert_equal('first again', getline(1)) + # compute range at runtime + :%del setline(1, range(1, 8)) @a = 'aaa' :$-2put a diff --git a/src/version.c b/src/version.c index f30ba25f5..3535adbee 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4319, /**/ 4318, /**/ diff --git a/src/vim9execute.c b/src/vim9execute.c index 6c79ff7df..961e4507c 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -4617,7 +4617,12 @@ exec_instructions(ectx_T *ectx) // :put! above cursor dir = BACKWARD; else if (lnum >= 0) - curwin->w_cursor.lnum = iptr->isn_arg.put.put_lnum; + { + curwin->w_cursor.lnum = lnum; + if (lnum == 0) + // check_cursor() below will move to line 1 + dir = BACKWARD; + } if (regname == '=') { -- cgit v1.2.1