diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-09-24 19:48:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 11:48:40 +0000 |
commit | 052875b9dc3de3283844a30dce9646f26982542d (patch) | |
tree | 15dd7b775c42ab3752919c1521d46d5b8bb5c2be /src/nvim/api/vim.c | |
parent | 3f6bc34e663c62bc8899dcdc65bf204b2ccfdaec (diff) | |
download | rneovim-052875b9dc3de3283844a30dce9646f26982542d.tar.gz rneovim-052875b9dc3de3283844a30dce9646f26982542d.tar.bz2 rneovim-052875b9dc3de3283844a30dce9646f26982542d.zip |
fix(paste): only record a paste when it's from RPC (#30491)
Problem: When using nvim_paste in a mapping during a macro recording,
both the mapping and the paste are recorded, causing the paste
to be performed twice when replaying the macro.
Solution: Only record a paste when it is from RPC.
Unfortunately this means there is no way for a script to make a recorded
paste. A way to enable that can be discussed later if there is need.
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index ae649e55d6..d18cfaccd0 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1248,7 +1248,8 @@ void nvim_set_current_tabpage(Tabpage tabpage, Error *err) /// @return /// - true: Client may continue pasting. /// - false: Client should cancel the paste. -Boolean nvim_paste(String data, Boolean crlf, Integer phase, Arena *arena, Error *err) +Boolean nvim_paste(uint64_t channel_id, String data, Boolean crlf, Integer phase, Arena *arena, + Error *err) FUNC_API_SINCE(6) FUNC_API_TEXTLOCK_ALLOW_CMDWIN { @@ -1273,13 +1274,13 @@ Boolean nvim_paste(String data, Boolean crlf, Integer phase, Arena *arena, Error cancelled = true; } if (!cancelled && (phase == -1 || phase == 1)) { - paste_store(kFalse, NULL_STRING, crlf); + paste_store(channel_id, kFalse, NULL_STRING, crlf); } if (!cancelled) { - paste_store(kNone, data, crlf); + paste_store(channel_id, kNone, data, crlf); } if (phase == 3 || phase == (cancelled ? 2 : -1)) { - paste_store(kTrue, NULL_STRING, crlf); + paste_store(channel_id, kTrue, NULL_STRING, crlf); } theend: ; |