From 95cc67538b00a8066ffa5c504b0a187fdc3eba36 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 14 Oct 2025 13:04:37 +0800 Subject: [PATCH] fix(clipboard): avoid using stale register width (#36178) Fix #36177 Follow-up to #35038 --- src/nvim/ops.c | 1 + test/functional/provider/clipboard_spec.lua | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 59e0f52598..677948f5dd 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -6697,6 +6697,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) reg->y_array = xcalloc((size_t)tv_list_len(lines), sizeof(String)); reg->y_size = (size_t)tv_list_len(lines); + reg->y_width = 0; // Will be updated by update_yankreg_width() below. reg->additional_data = NULL; reg->timestamp = 0; // Timestamp is not saved for clipboard registers because clipboard registers diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua index 3666112003..95bbc98c5b 100644 --- a/test/functional/provider/clipboard_spec.lua +++ b/test/functional/provider/clipboard_spec.lua @@ -563,6 +563,12 @@ describe('clipboard (with fake clipboard.vim)', function() あいあいあいうえお xxx xxx xx xx]]) + feed('G0ky') + feed('P') + expect([[ + あいあいあいうえお + xxxx xxx + xxx xx]]) end) end)