diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2017-05-31 23:43:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-31 23:43:40 +0200 |
| commit | 133f8bc628c20510571a9f6c93b61a14521327d1 (patch) | |
| tree | a0d8fdef972c4d203e76b914720f78b404beeffe /src/nvim/ops.c | |
| parent | c1026ff4b3b6500c06d5a2233214addbb41936cb (diff) | |
| parent | 2f2eeb19ba7ba6f8b7789d7d10c9e821d4ea3351 (diff) | |
| download | rneovim-133f8bc628c20510571a9f6c93b61a14521327d1.tar.gz rneovim-133f8bc628c20510571a9f6c93b61a14521327d1.tar.bz2 rneovim-133f8bc628c20510571a9f6c93b61a14521327d1.zip | |
Merge #4700 from AdnoC/keep-default-register
Diffstat (limited to 'src/nvim/ops.c')
| -rw-r--r-- | src/nvim/ops.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index c77781b1d1..e374686286 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5780,7 +5780,7 @@ static inline bool reg_empty(const yankreg_T *const reg) /// @return Pointer that needs to be passed to next `op_register_iter` call or /// NULL if iteration is over. const void *op_register_iter(const void *const iter, char *const name, - yankreg_T *const reg) + yankreg_T *const reg, bool *is_unnamed) FUNC_ATTR_NONNULL_ARG(2, 3) FUNC_ATTR_WARN_UNUSED_RESULT { *name = NUL; @@ -5796,6 +5796,7 @@ const void *op_register_iter(const void *const iter, char *const name, int iter_off = (int)(iter_reg - &(y_regs[0])); *name = (char)get_register_name(iter_off); *reg = *iter_reg; + *is_unnamed = (iter_reg == y_previous); while (++iter_reg - &(y_regs[0]) < NUM_SAVED_REGISTERS) { if (!reg_empty(iter_reg)) { return (void *) iter_reg; @@ -5820,10 +5821,11 @@ size_t op_register_amount(void) /// Set register to a given value /// /// @param[in] name Register name. -/// @param[in] reg Register value. +/// @param[in] reg Register value. +/// @param[in] is_unnamed Whether to set the unnamed regiseter to reg /// /// @return true on success, false on failure. -bool op_register_set(const char name, const yankreg_T reg) +bool op_register_set(const char name, const yankreg_T reg, bool is_unnamed) { int i = op_reg_index(name); if (i == -1) { @@ -5831,6 +5833,10 @@ bool op_register_set(const char name, const yankreg_T reg) } free_register(&y_regs[i]); y_regs[i] = reg; + + if (is_unnamed) { + y_previous = &y_regs[i]; + } return true; } @@ -5847,3 +5853,20 @@ const yankreg_T *op_register_get(const char name) } return &y_regs[i]; } + +/// Set the previous yank register +/// +/// @param[in] name Register name. +/// +/// @return true on success, false on failure. +bool op_register_set_previous(const char name) + FUNC_ATTR_WARN_UNUSED_RESULT +{ + int i = op_reg_index(name); + if (i == -1) { + return false; + } + + y_previous = &y_regs[i]; + return true; +} |
