aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-08-26 03:15:09 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-08-27 22:13:45 +0200
commit4344ac11119abd20ba911d72cf540321277dd150 (patch)
tree59eaf35103fb7cd8fdc6c3bf96703b4d3dbf46e8 /src
parent5b41070c639f979023178042bea8e5fcc8a898fe (diff)
downloadrneovim-4344ac11119abd20ba911d72cf540321277dd150.tar.gz
rneovim-4344ac11119abd20ba911d72cf540321277dd150.tar.bz2
rneovim-4344ac11119abd20ba911d72cf540321277dd150.zip
paste: tickle cursor
HACK: The cursor does not get repositioned after the paste completes. Scheduling a dummy event seems to fix it. Test case: 0. Revert this commit. 1. Paste some text in Normal-mode. 2. Notice the cursor is still in the cmdline area.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/vim.c8
-rw-r--r--src/nvim/event/loop.c4
-rw-r--r--src/nvim/tui/tui.c6
3 files changed, 11 insertions, 7 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 6d6fd85266..3631fbff66 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1252,11 +1252,15 @@ Boolean nvim_paste(String data, Integer phase, Error *err)
}
}
}
+ api_free_object(rv);
+ api_free_array(args);
if (!(State & CMDLINE) && !(State & INSERT) && (phase == -1 || phase == 3)) {
AppendCharToRedobuff(ESC); // Dot-repeat.
}
- api_free_object(rv);
- api_free_array(args);
+ if (phase == -1 || phase == 3) {
+ // XXX: Tickle main loop to ensure cursor is updated.
+ loop_schedule_deferred(&main_loop, event_create(loop_dummy_event, 0));
+ }
return ok;
}
diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c
index 93ec28bb81..529ddd8eba 100644
--- a/src/nvim/event/loop.c
+++ b/src/nvim/event/loop.c
@@ -162,6 +162,10 @@ size_t loop_size(Loop *loop)
return rv;
}
+void loop_dummy_event(void **argv)
+{
+}
+
static void async_cb(uv_async_t *handle)
{
Loop *l = handle->loop->data;
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 9fdc6eceba..ea8f9d9f71 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -430,7 +430,7 @@ static void tui_main(UIBridgeData *bridge, UI *ui)
tui_terminal_after_startup(ui);
// Tickle `main_loop` with a dummy event, else the initial "focus-gained"
// terminal response may not get processed until user hits a key.
- loop_schedule_deferred(&main_loop, event_create(tui_dummy_event, 0));
+ loop_schedule_deferred(&main_loop, event_create(loop_dummy_event, 0));
}
// "Passive" (I/O-driven) loop: TUI thread "main loop".
while (!tui_is_stopped(ui)) {
@@ -449,10 +449,6 @@ static void tui_main(UIBridgeData *bridge, UI *ui)
xfree(data);
}
-static void tui_dummy_event(void **argv)
-{
-}
-
/// Handoff point between the main (ui_bridge) thread and the TUI thread.
static void tui_scheduler(Event event, void *d)
{