aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/ops.c26
-rw-r--r--test/functional/clipboard/clipboard_provider_spec.lua7
3 files changed, 34 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 80f9b47340..54e5bcb9ff 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -5718,6 +5718,7 @@ static int ex_window(void)
i = RedrawingDisabled;
RedrawingDisabled = 0;
+ int save_count = save_batch_count();
/*
* Call the main loop until <CR> or CTRL-C is typed.
@@ -5726,6 +5727,7 @@ static int ex_window(void)
normal_enter(true, false);
RedrawingDisabled = i;
+ restore_batch_count(save_count);
int save_KeyTyped = KeyTyped;
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 99dc4670f1..e7bc20698b 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5755,7 +5755,6 @@ void start_batch_changes(void)
return;
}
clipboard_delay_update = true;
- clipboard_needs_update = false;
}
/// Counterpart to start_batch_changes().
@@ -5767,12 +5766,37 @@ void end_batch_changes(void)
}
clipboard_delay_update = false;
if (clipboard_needs_update) {
+ // must be before, as set_clipboard will invoke
+ // start/end_batch_changes recursively
+ clipboard_needs_update = false;
// unnamed ("implicit" clipboard)
set_clipboard(NUL, y_previous);
+ }
+}
+
+int save_batch_count(void)
+{
+ int save_count = batch_change_count;
+ batch_change_count = 0;
+ clipboard_delay_update = false;
+ if (clipboard_needs_update) {
clipboard_needs_update = false;
+ // unnamed ("implicit" clipboard)
+ set_clipboard(NUL, y_previous);
}
+ return save_count;
}
+void restore_batch_count(int save_count)
+{
+ assert(batch_change_count == 0);
+ batch_change_count = save_count;
+ if (batch_change_count > 0) {
+ clipboard_delay_update = true;
+ }
+}
+
+
/// Check whether register is empty
static inline bool reg_empty(const yankreg_T *const reg)
FUNC_ATTR_PURE
diff --git a/test/functional/clipboard/clipboard_provider_spec.lua b/test/functional/clipboard/clipboard_provider_spec.lua
index f66fbf7c94..b90335e70a 100644
--- a/test/functional/clipboard/clipboard_provider_spec.lua
+++ b/test/functional/clipboard/clipboard_provider_spec.lua
@@ -392,6 +392,13 @@ describe('clipboard', function()
eq('---', eval('getreg("*")'))
end)
+ it('works in the cmdline window', function()
+ feed('q:itext<esc>yy')
+ eq({{'text', ''}, 'V'}, eval("g:test_clip['*']"))
+ command("let g:test_clip['*'] = [['star'], 'c']")
+ feed('p')
+ eq('textstar', meths.get_current_line())
+ end)
end)
describe('clipboard=unnamedplus', function()