documents: Ctrl+V with no block open pastes text at the caret
It pasted only pictures; text was dropped without a word. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
013f14216f
commit
1b5fb07cda
3 files changed
+17
-2
No files matched your search
@@ -124,3 +124,12 @@ fn delete_image_takes_the_picture_away_in_one_step(cx: &mut TestAppContext) {
|
||||
editor.update(cx, |editor, cx| editor.undo(cx));
|
||||
assert_eq!(text(&document, cx), source);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn text_pastes_at_the_caret_with_no_block_open(cx: &mut TestAppContext) {
|
||||
let (document, cx) = open("First.\n", MarkdownMode::Visual, cx);
|
||||
press_on(0, 0, MouseButton::Right, cx);
|
||||
cx.write_to_clipboard(gpui::ClipboardItem::new_string("New ".into()));
|
||||
cx.simulate_keystrokes("secondary-v");
|
||||
assert_eq!(text(&document, cx), "New First.\n");
|
||||
}
|
||||
@@ -281,7 +281,13 @@ impl Render for MarkdownDocument {
|
||||
}
|
||||
}))
|
||||
.on_action(cx.listener(|document, _: &Paste, _, cx| {
|
||||
document.paste_picture(cx);
|
||||
if document.paste_picture(cx) {
|
||||
return;
|
||||
}
|
||||
match cx.read_from_clipboard().and_then(|item| item.text()) {
|
||||
Some(text) => _ = document.insert(&text, cx),
|
||||
None => log::info!("markdown document: nothing to paste"),
|
||||
}
|
||||
}))
|
||||
.capture_action(cx.listener(|document, _: &forms::Enter, _, cx| {
|
||||
if document.block_newline(cx) {
|
||||
|
||||
Reference in new issue
Block a user