aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-03-27 09:06:46 +0800
committerGitHub <noreply@github.com>2025-03-27 01:06:46 +0000
commit750e1836afb49b860fa11b4336a7ae351720a553 (patch)
treed46b75c6d0bc947fcfc268e2e103e6fdf1a9547a /src/nvim/ex_docmd.c
parent8f40ffdb92b6ca25529b470e4a4e2bb7ddbb000a (diff)
downloadrneovim-750e1836afb49b860fa11b4336a7ae351720a553.tar.gz
rneovim-750e1836afb49b860fa11b4336a7ae351720a553.tar.bz2
rneovim-750e1836afb49b860fa11b4336a7ae351720a553.zip
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 https://github.com/vim/vim/commit/e08f10a55c3f15b0b4af631908551d88ec4fe502 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>
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 640c729e3b..6c5cca5d5c 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -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)
{