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

This commit is contained in:
Martin Ball
2026-11-19 13:22:00 +00:00
parent a54108ab1e
commit 91d09846e9
3 changed files with 20 additions and 4 deletions
+5 -3
View File
@@ -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<Option<Vec<PathBuf>>, 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 {
+12
View File
@@ -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"));
}
+3 -1
View File
@@ -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,
}