mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
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.
This commit is contained in:
@@ -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:
|
||||
;
|
||||
|
Reference in New Issue
Block a user