mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 23:48:32 +00:00
feat(editor)!: insert-mode ctrl-r should work like paste #35477
Problem: insert-mode ctrl-r input is treated like raw user input, which is almost never useful. This means any newlines in the input are affected by autoindent, etc., which is: - slow - usually breaks the formatting of the input Solution: - ctrl-r should be treated like a paste, not user-input. - does not affect `<c-r>=`, so `<c-r>=@x` can still be used to get the old behavior. Co-authored-by: Justin M. Keyes <justinkz@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
@@ -2854,6 +2854,8 @@ static void ins_reg(void)
|
||||
vim_beep(kOptBoFlagRegister);
|
||||
need_redraw = true; // remove the '"'
|
||||
} else {
|
||||
yankreg_T *reg = get_yank_register(regname, YREG_PASTE);
|
||||
|
||||
if (literally == Ctrl_O || literally == Ctrl_P) {
|
||||
// Append the command to the redo buffer.
|
||||
AppendCharToRedobuff(Ctrl_R);
|
||||
@@ -2862,7 +2864,11 @@ static void ins_reg(void)
|
||||
|
||||
do_put(regname, NULL, BACKWARD, 1,
|
||||
(literally == Ctrl_P ? PUT_FIXINDENT : 0) | PUT_CURSEND);
|
||||
} else if (insert_reg(regname, NULL, literally) == FAIL) {
|
||||
} else if (reg->y_size > 1 && is_literal_register(regname)) {
|
||||
AppendCharToRedobuff(Ctrl_R);
|
||||
AppendCharToRedobuff(regname);
|
||||
do_put(regname, NULL, BACKWARD, 1, PUT_CURSEND);
|
||||
} else if (insert_reg(regname, NULL, !!literally) == FAIL) {
|
||||
vim_beep(kOptBoFlagRegister);
|
||||
need_redraw = true; // remove the '"'
|
||||
} else if (stop_insert_mode) {
|
||||
|
@@ -152,7 +152,7 @@ static inline int op_reg_index(const int regname)
|
||||
static inline bool is_literal_register(const int regname)
|
||||
FUNC_ATTR_CONST
|
||||
{
|
||||
return regname == '*' || regname == '+';
|
||||
return regname == '*' || regname == '+' || ASCII_ISALNUM(regname);
|
||||
}
|
||||
|
||||
EXTERN LuaRef repeat_luaref INIT( = LUA_NOREF); ///< LuaRef for "."
|
||||
|
Reference in New Issue
Block a user