From 9cebcc8d7fc6dea42402b08d83ca84c4698af6c0 Mon Sep 17 00:00:00 2001 From: Joansitoh Date: Tue, 27 Oct 2026 00:59:55 +0100 Subject: [PATCH] Launcher: a paste keeps the spaces at its ends Pasting " --world Test" after an argument lost its leading space and joined the two arguments. The first line of the clipboard is inserted as it is. --- launcher/src/line_edit.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/launcher/src/line_edit.rs b/launcher/src/line_edit.rs index 0647f5861..2889eb5f1 100644 --- a/launcher/src/line_edit.rs +++ b/launcher/src/line_edit.rs @@ -407,6 +407,12 @@ impl LineEdit { } } +/// What a paste puts in a one-line field: the clipboard's first line, spaces at its ends kept +/// (` --world Test` after an argument is a new argument). +fn pasted(clipboard: &str) -> &str { + clipboard.lines().next().unwrap_or_default() +} + /// The keyboard in a field: moves the caret, edits, copies and pastes. Never returns Paste, Copy /// or Cut (they are done); Enter, Escape and Pass are the page's. pub(super) fn handle(edit: &mut LineEdit, ev: &KeyDownEvent, cx: &mut App) -> Key { @@ -415,7 +421,7 @@ pub(super) fn handle(edit: &mut LineEdit, ev: &KeyDownEvent, cx: &mut App) -> Ke match edit.key(&k.key, k.key_char.as_deref(), command, k.modifiers.shift) { Key::Paste => { if let Some(text) = cx.read_from_clipboard().and_then(|c| c.text()) { - edit.insert(text.lines().next().unwrap_or_default().trim()); + edit.insert(pasted(&text)); } Key::Edited }