mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 08:18:17 +00:00
clipboard: remove start_batch_changes() in redir_write()
start_batch_changes() doesn't avoid invoking the clipboard once-per-line, because the loop is actually in ex_echo(), which calls redir_write() for each message. But we've already entered start_batch_changes() by then, so that was never the problem. redir_write at /home/vagrant/old.neovim/build/../src/nvim/message.c:2523 msg_puts_attr_len at /home/vagrant/old.neovim/build/../src/nvim/message.c:1600 msg_outtrans_len_attr at /home/vagrant/old.neovim/build/../src/nvim/message.c:1221 ex_echo at /home/vagrant/old.neovim/build/../src/nvim/eval.c:19433 do_one_cmd at /home/vagrant/old.neovim/build/../src/nvim/ex_docmd.c:2242 Trying to defer _explicit_ clipboard updates is difficult. :redir @+ | silent echo system('cat foo') | redir END is essentially equivalent to: for l in readfile('foo') let @+ .= l endfor We cannot make judgements about when to ignore a script's bad decisions. start_batch_changes() only works around the case of clipboard=unnamed, i.e. _implicit_ clipboard updates (`:g/foo/d`). Not explicit assignment.
This commit is contained in:
@@ -5558,7 +5558,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing)
|
||||
msg((char_u *)MSG_NO_CLIP);
|
||||
clipboard_didwarn_unnamed = true;
|
||||
}
|
||||
// ... else, be silent (avoid a flood of messages).
|
||||
// ... else, be silent (don't flood during :while, :redir, etc.).
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -5567,10 +5567,12 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing)
|
||||
goto end;
|
||||
} else { // unnamed register: "implicit" clipboard
|
||||
if (writing && clipboard_delay_update) {
|
||||
// For "set" (copy), defer the clipboard call.
|
||||
clipboard_needs_update = true;
|
||||
goto end;
|
||||
} else if (!writing && clipboard_needs_update) {
|
||||
goto end; // use the internal value
|
||||
// For "get" (paste), use the internal value.
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (cb_flags & CB_UNNAMEDPLUS) {
|
||||
@@ -5772,6 +5774,7 @@ void end_batch_changes(void)
|
||||
}
|
||||
clipboard_delay_update = false;
|
||||
if (clipboard_needs_update) {
|
||||
// unnamed ("implicit" clipboard)
|
||||
set_clipboard(NUL, y_previous);
|
||||
clipboard_needs_update = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user