diff options
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 50710cd78a..2714798368 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -45,6 +45,7 @@ #include "nvim/screen.h" #include "nvim/search.h" #include "nvim/strings.h" +#include "nvim/terminal.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/window.h" @@ -2643,11 +2644,13 @@ do_put ( return; } - /* Autocommands may be executed when saving lines for undo, which may make - * y_array invalid. Start undo now to avoid that. */ - if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL) { - ELOG(_("Failed to save undo information")); - return; + if (!curbuf->terminal) { + // Autocommands may be executed when saving lines for undo, which may make + // y_array invalid. Start undo now to avoid that. + if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL) { + ELOG(_("Failed to save undo information")); + return; + } } if (insert_string != NULL) { @@ -2692,6 +2695,20 @@ do_put ( y_array = y_current->y_array; } + if (curbuf->terminal) { + for (int i = 0; i < count; i++) { + // feed the lines to the terminal + for (int j = 0; j < y_size; j++) { + if (j) { + // terminate the previous line + terminal_send(curbuf->terminal, "\n", 1); + } + terminal_send(curbuf->terminal, (char *)y_array[j], STRLEN(y_array[j])); + } + } + return; + } + if (y_type == MLINE) { if (flags & PUT_LINE_SPLIT) { /* "p" or "P" in Visual mode: split the lines to put the text in |