From 91d09846e95b97c0ff09a6f8c78fe2888ffbd220 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Thu, 19 Nov 2026 13:22:00 +0000 Subject: [PATCH] rf-platform: MemoryClipboard reads a held text/uri-list as files; size.pane.least's doc says it is a floor, not a pane body width --- crates/platform/src/clipboard/memory.rs | 8 +++++--- crates/platform/src/clipboard_tests.rs | 12 ++++++++++++ crates/theme/src/tokens/size.rs | 4 +++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/platform/src/clipboard/memory.rs b/crates/platform/src/clipboard/memory.rs index b44657fc6..dca27b2de 100644 --- a/crates/platform/src/clipboard/memory.rs +++ b/crates/platform/src/clipboard/memory.rs @@ -3,8 +3,8 @@ use std::path::PathBuf; use super::backend::ClipboardBackend; -use super::convert::rgba8_image; -use super::types::{BITMAP, ClipboardError, ClipboardImage, Flavor, RGBA8}; +use super::convert::{parse_uri_list, rgba8_image}; +use super::types::{BITMAP, ClipboardError, ClipboardImage, Flavor, RGBA8, URI_LIST}; /// The public in-memory clipboard for tests and hosts without one. It enforces no limits; the /// [`Clipboard`](super::Clipboard) over it does. @@ -34,8 +34,10 @@ impl ClipboardBackend for MemoryClipboard { Ok(self.find(RGBA8).and_then(|flavor| rgba8_image(&flavor.data))) } + /// A held text/uri-list, one file:// URI per line, read as the event clipboard reads an offered one. fn read_files(&mut self, _limit: usize) -> Result>, ClipboardError> { - Ok(None) + let files = self.find(URI_LIST).map(|flavor| parse_uri_list(&String::from_utf8_lossy(&flavor.data))); + Ok(files.filter(|files| !files.is_empty())) } fn has(&mut self, mimes: &[&str]) -> bool { diff --git a/crates/platform/src/clipboard_tests.rs b/crates/platform/src/clipboard_tests.rs index e132204a5..a925e881f 100644 --- a/crates/platform/src/clipboard_tests.rs +++ b/crates/platform/src/clipboard_tests.rs @@ -22,3 +22,15 @@ fn synthetic_input_never_replaces_what_the_user_copied() { assert_eq!(clipboard.write_text("mine").unwrap(), Written::Written); assert_eq!(clipboard.read_text().unwrap().as_deref(), Some("mine")); } + +// Copied files arrive as a text/uri-list. A backend that holds the list but answers no files +// turns every file paste in tests, and in hosts without a system clipboard, into a no-op. +#[test] +fn a_held_uri_list_reads_as_files() { + let mut clipboard = Clipboard::new(MemoryClipboard::default()); + let list = "# copied\r\nfile:///tmp/a%20b.txt\r\nfile:///tmp/c.csv\r\n"; + clipboard.backend_mut().write(&[Flavor::new(URI_LIST, list.as_bytes().to_vec())]).unwrap(); + let files = clipboard.read_files().unwrap().unwrap(); + assert_eq!(files.len(), 2); + assert!(files[0].ends_with("a b.txt") && files[1].ends_with("c.csv")); +} diff --git a/crates/theme/src/tokens/size.rs b/crates/theme/src/tokens/size.rs index 8896e6f0f..461a4fd21 100644 --- a/crates/theme/src/tokens/size.rs +++ b/crates/theme/src/tokens/size.rs @@ -273,7 +273,9 @@ pub struct RulerTickSizes { /// The sizes of the panes of a dock's split, in logical pixels. #[derive(Clone, Copy, Debug, Default, PartialEq)] pub struct PaneSizes { - /// The least extent of a pane along a split, and of a dock, before its panels' own limits. + /// The least extent of a pane along a split, of a dock, and of an edge pane its grip is dragged to: a floor + /// beneath the panels' own limits, not a width their content is laid out to fit. A task pane's least body width + /// is its own (`PaneSpec::limits`), from its content. pub least: f32, }