documents: right presses keep a selection; Delete Image
A right press in a text field or the code editor keeps a selection it lands in, else moves the caret. In visual mode a right press in the open block keeps it open and emits Pointed, read apart from the whole text. MarkdownDocument::delete_image removes the picture at the caret. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6c2d28c56e
commit
013f14216f
9 files changed
+284
-5
No files matched your search
@@ -7,7 +7,7 @@ use gpui::{AppContext as _, Context};
|
||||
use super::{
|
||||
DocumentEvent, LARGEST_READ, MarkdownDocument,
|
||||
block::{self, BlockCommand, settled},
|
||||
format::{Change, EditRefusal, InlineFormat, toggle},
|
||||
format::{Change, EditRefusal, InlineFormat, drop_image, toggle},
|
||||
tables::{self, TableEdit},
|
||||
};
|
||||
use crate::documents::{MarkdownMode, modes::joint};
|
||||
@@ -29,6 +29,11 @@ impl MarkdownDocument {
|
||||
)
|
||||
}
|
||||
|
||||
/// Removes the picture at the caret, read apart.
|
||||
pub fn delete_image(&mut self, cx: &mut Context<Self>) -> Result<(), EditRefusal> {
|
||||
self.apart("delete image".to_string(), drop_image, cx)
|
||||
}
|
||||
|
||||
/// `command` at the caret, read apart; refusals by event.
|
||||
pub fn block(
|
||||
&mut self,
|
||||
@@ -107,7 +112,7 @@ impl MarkdownDocument {
|
||||
}
|
||||
|
||||
/// The text an edit reads: the open block's in place.
|
||||
fn snapshot(&self, cx: &Context<Self>) -> Snapshot {
|
||||
pub(super) fn snapshot(&self, cx: &Context<Self>) -> Snapshot {
|
||||
let text = self.editor.read(cx).text();
|
||||
let Some(open) = &self.open else {
|
||||
let picked = self.editor.read(cx).primary().range();
|
||||
|
||||
Reference in new issue
Block a user