Windows: Fix crash when trying to copy nothing to clipboard (#10405)

usr created

Release Notes:

- N/A

Change summary

crates/gpui/src/platform/windows/platform.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

Detailed changes

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<ClipboardItem> {