aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-09-22 06:02:48 +0800
committerGitHub <noreply@github.com>2024-09-22 06:02:48 +0800
commite697c1b43dfbeab132fee4149157f7abd08c51a0 (patch)
tree4fb363d573f9606f7314799e03c6ba9e0f5fd0e1 /src/nvim/api/vim.c
parent1d815acd78e5b961302985b80d2b625947902386 (diff)
downloadrneovim-e697c1b43dfbeab132fee4149157f7abd08c51a0.tar.gz
rneovim-e697c1b43dfbeab132fee4149157f7abd08c51a0.tar.bz2
rneovim-e697c1b43dfbeab132fee4149157f7abd08c51a0.zip
fix(paste): improve repeating of pasted text (#30438)
- Fixes 'autoindent' being applied during redo. - Makes redoing a large paste significantly faster. - Stores pasted text in the register being recorded. Fix #28561
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index d10ee91042..4b80369654 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1259,30 +1259,19 @@ Boolean nvim_paste(String data, Boolean crlf, Integer phase, Arena *arena, Error
draining = true;
goto theend;
}
- if (!(State & (MODE_CMDLINE | MODE_INSERT)) && (phase == -1 || phase == 1)) {
- ResetRedobuff();
- AppendCharToRedobuff('a'); // Dot-repeat.
+ if (phase == -1 || phase == 1) {
+ paste_store(kFalse, NULL_STRING, crlf);
}
// vim.paste() decides if client should cancel. Errors do NOT cancel: we
// want to drain remaining chunks (rather than divert them to main input).
cancel = (rv.type == kObjectTypeBoolean && !rv.data.boolean);
- if (!cancel && !(State & MODE_CMDLINE)) { // Dot-repeat.
- for (size_t i = 0; i < lines.size; i++) {
- String s = lines.items[i].data.string;
- assert(s.size <= INT_MAX);
- AppendToRedobuffLit(s.data, (int)s.size);
- // readfile()-style: "\n" is indicated by presence of N+1 item.
- if (i + 1 < lines.size) {
- AppendCharToRedobuff(NL);
- }
- }
- }
- if (!(State & (MODE_CMDLINE | MODE_INSERT)) && (phase == -1 || phase == 3)) {
- AppendCharToRedobuff(ESC); // Dot-repeat.
+ if (!cancel) {
+ paste_store(kNone, data, crlf);
}
theend:
if (cancel || phase == -1 || phase == 3) { // End of paste-stream.
draining = false;
+ paste_store(kTrue, NULL_STRING, crlf);
}
return !cancel;