mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 03:58:32 +00:00
vim-patch:9.1.1224: cannot :put while keeping indent (#33076)
Problem: cannot :put while keeping indent (Peter Aronoff)
Solution: add the :iput ex command (64-bitman)
fixes: vim/vim#16225
closes: vim/vim#16886
e08f10a55c
Cherry-pick test_put.vim changes from patch 8.2.1593.
N/A patches:
vim-patch:9.1.1213: cannot :put while keeping indent
vim-patch:9.1.1215: Patch 9.1.1213 has some issues
Co-authored-by: 64-bitman <60551350+64-bitman@users.noreply.github.com>
Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
This commit is contained in:
@@ -504,7 +504,9 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Arena
|
||||
VALIDATE((regname != '='), "%s", "Cannot use register \"=", {
|
||||
goto end;
|
||||
});
|
||||
VALIDATE(valid_yank_reg(regname, ea.cmdidx != CMD_put && !IS_USER_CMDIDX(ea.cmdidx)),
|
||||
VALIDATE(valid_yank_reg(regname,
|
||||
(!IS_USER_CMDIDX(ea.cmdidx)
|
||||
&& ea.cmdidx != CMD_put && ea.cmdidx != CMD_iput)),
|
||||
"Invalid register: \"%c", regname, {
|
||||
goto end;
|
||||
});
|
||||
|
@@ -1218,6 +1218,12 @@ M.cmds = {
|
||||
addr_type = 'ADDR_NONE',
|
||||
func = 'ex_intro',
|
||||
},
|
||||
{
|
||||
command = 'iput',
|
||||
flags = bit.bor(RANGE, WHOLEFOLD, BANG, REGSTR, TRLBAR, ZEROR, CMDWIN, LOCK_OK, MODIFY),
|
||||
addr_type = 'ADDR_LINES',
|
||||
func = 'ex_iput',
|
||||
},
|
||||
{
|
||||
command = 'isearch',
|
||||
flags = bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK),
|
||||
|
@@ -1393,8 +1393,9 @@ static void parse_register(exarg_T *eap)
|
||||
// Do not allow register = for user commands
|
||||
&& (!IS_USER_CMDIDX(eap->cmdidx) || *eap->arg != '=')
|
||||
&& !((eap->argt & EX_COUNT) && ascii_isdigit(*eap->arg))) {
|
||||
if (valid_yank_reg(*eap->arg, (eap->cmdidx != CMD_put
|
||||
&& !IS_USER_CMDIDX(eap->cmdidx)))) {
|
||||
if (valid_yank_reg(*eap->arg,
|
||||
(!IS_USER_CMDIDX(eap->cmdidx)
|
||||
&& eap->cmdidx != CMD_put && eap->cmdidx != CMD_iput))) {
|
||||
eap->regname = (uint8_t)(*eap->arg++);
|
||||
// for '=' register: accept the rest of the line as an expression
|
||||
if (eap->arg[-1] == '=' && eap->arg[0] != NUL) {
|
||||
@@ -1752,7 +1753,7 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview)
|
||||
|
||||
if (!MODIFIABLE(curbuf) && (eap->argt & EX_MODIFY)
|
||||
// allow :put in terminals
|
||||
&& !(curbuf->terminal && eap->cmdidx == CMD_put)) {
|
||||
&& !(curbuf->terminal && (eap->cmdidx == CMD_put || eap->cmdidx == CMD_iput))) {
|
||||
errormsg = _(e_modifiable);
|
||||
goto end;
|
||||
}
|
||||
@@ -2155,7 +2156,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
|
||||
}
|
||||
if (!MODIFIABLE(curbuf) && (ea.argt & EX_MODIFY)
|
||||
// allow :put in terminals
|
||||
&& (!curbuf->terminal || ea.cmdidx != CMD_put)) {
|
||||
&& !(curbuf->terminal && (ea.cmdidx == CMD_put || ea.cmdidx == CMD_iput))) {
|
||||
// Command not allowed in non-'modifiable' buffer
|
||||
errormsg = _(e_modifiable);
|
||||
goto doend;
|
||||
@@ -6306,6 +6307,20 @@ static void ex_put(exarg_T *eap)
|
||||
PUT_LINE|PUT_CURSLINE);
|
||||
}
|
||||
|
||||
/// ":iput".
|
||||
static void ex_iput(exarg_T *eap)
|
||||
{
|
||||
// ":0iput" works like ":1iput!".
|
||||
if (eap->line2 == 0) {
|
||||
eap->line2 = 1;
|
||||
eap->forceit = true;
|
||||
}
|
||||
curwin->w_cursor.lnum = eap->line2;
|
||||
check_cursor_col(curwin);
|
||||
do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1L,
|
||||
PUT_LINE|PUT_CURSLINE|PUT_FIXINDENT);
|
||||
}
|
||||
|
||||
/// Handle ":copy" and ":move".
|
||||
static void ex_copymove(exarg_T *eap)
|
||||
{
|
||||
|
Reference in New Issue
Block a user