commit 49983387ffd54fe0888f17098e43318a443315ac
parent f49408454ddb48016d51b48bcd9d5dab538f5cc7
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed, 10 Apr 2024 08:50:36 +0800
fix(prompt): emit change event for prompt newline (#28260)
Co-authored-by: Ilia Choly <ilia.choly@gmail.com>
Diffstat:
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
@@ -17,6 +17,7 @@
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
+#include "nvim/change.h"
#include "nvim/channel.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
@@ -8905,6 +8906,7 @@ void invoke_prompt_callback(void)
// Add a new line for the prompt before invoking the callback, so that
// text can always be inserted above the last line.
ml_append(lnum, "", 0, false);
+ appended_lines_mark(lnum, 1);
curwin->w_cursor.lnum = lnum + 1;
curwin->w_cursor.col = 0;
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
@@ -1266,6 +1266,25 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)
+ it('prompt buffer', function()
+ local check_events = setup_eventcheck(verify, {})
+ api.nvim_set_option_value('buftype', 'prompt', {})
+ feed('i')
+ check_events {
+ { 'test1', 'bytes', 1, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2 },
+ }
+ feed('<CR>')
+ check_events {
+ { 'test1', 'bytes', 1, 4, 1, 0, 3, 0, 0, 0, 1, 0, 1 },
+ { 'test1', 'bytes', 1, 5, 1, 0, 3, 0, 0, 0, 0, 2, 2 },
+ }
+ feed('<CR>')
+ check_events {
+ { 'test1', 'bytes', 1, 6, 2, 0, 6, 0, 0, 0, 1, 0, 1 },
+ { 'test1', 'bytes', 1, 7, 2, 0, 6, 0, 0, 0, 0, 2, 2 },
+ }
+ end)
+
local function test_lockmarks(mode)
local description = (mode ~= '') and mode or '(baseline)'
it('test_lockmarks ' .. description .. ' %delete _', function()