feat(advancedpaste): verify clipboard copy with sequence

This commit is contained in:
Gordon Lam (SH)
2026-01-31 09:27:14 -08:00
parent b5f08dbb78
commit d4d6a6e84e

View File

@@ -519,9 +519,12 @@ private:
{
constexpr int copy_attempts = 2;
constexpr auto copy_retry_delay = std::chrono::milliseconds(100);
constexpr int clipboard_poll_attempts = 5;
constexpr auto clipboard_poll_delay = std::chrono::milliseconds(30);
for (int attempt = 0; attempt < copy_attempts; ++attempt)
{
const auto initial_sequence = GetClipboardSequenceNumber();
bool copy_succeeded = try_send_copy_message();
if (!copy_succeeded)
@@ -579,6 +582,23 @@ private:
}
}
if (copy_succeeded)
{
bool sequence_changed = false;
for (int poll_attempt = 0; poll_attempt < clipboard_poll_attempts; ++poll_attempt)
{
if (GetClipboardSequenceNumber() != initial_sequence)
{
sequence_changed = true;
break;
}
std::this_thread::sleep_for(clipboard_poll_delay);
}
copy_succeeded = sequence_changed;
}
if (copy_succeeded)
{
break;