From cb6d0639db0e23ac77e9f75a97953b55a1147af1 Mon Sep 17 00:00:00 2001 From: usr <81042605+a-usr@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:33:20 +0200 Subject: [PATCH] Windows: Fix crash when trying to copy nothing to clipboard (#10405) Release Notes: - N/A --- crates/gpui/src/platform/windows/platform.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs index f59a8672f7..a4a7d6249e 100644 --- a/crates/gpui/src/platform/windows/platform.rs +++ b/crates/gpui/src/platform/windows/platform.rs @@ -687,8 +687,10 @@ impl Platform for WindowsPlatform { } fn write_to_clipboard(&self, item: ClipboardItem) { - let mut ctx = ClipboardContext::new().unwrap(); - ctx.set_contents(item.text().to_owned()).unwrap(); + if item.text.len() > 0 { + let mut ctx = ClipboardContext::new().unwrap(); + ctx.set_contents(item.text().to_owned()).unwrap(); + } } fn read_from_clipboard(&self) -> Option {