typography and documents: an exported formula frames its outlined text; rendered modes have no source selection
This commit is contained in:
4 files changed
+42
-9
No files matched your search
@@ -31,6 +31,10 @@ impl MarkdownDocument {
|
||||
/// The selected Markdown: the source's, or the open block's.
|
||||
pub fn selected(&self, cx: &App) -> String {
|
||||
let Some(open) = &self.open else {
|
||||
// Rendered modes show no source selection.
|
||||
if !matches!(self.mode, MarkdownMode::Source | MarkdownMode::Split) {
|
||||
return String::new();
|
||||
}
|
||||
let editor = self.editor.read(cx);
|
||||
return editor.text()[editor.primary().range()].to_string();
|
||||
};
|
||||
|
||||
@@ -211,10 +211,14 @@ fn the_selection_reads_in_source_and_in_an_open_block(cx: &mut TestAppContext) {
|
||||
document.read_with(cx, |document, cx| document.selected(cx)),
|
||||
"One"
|
||||
);
|
||||
document.update_in(cx, |document, window, cx| {
|
||||
document.set_mode(MarkdownMode::Visual, window, cx)
|
||||
});
|
||||
frames(cx);
|
||||
for mode in [MarkdownMode::Preview, MarkdownMode::Visual] {
|
||||
document.update_in(cx, |document, window, cx| {
|
||||
document.set_mode(mode, window, cx)
|
||||
});
|
||||
frames(cx);
|
||||
let selected = document.read_with(cx, |document, cx| document.selected(cx));
|
||||
assert_eq!(selected, "", "{mode:?} shows no source selection");
|
||||
}
|
||||
super::type_in(&document, Some(1), None, cx);
|
||||
document.update(cx, |document, cx| {
|
||||
let open = document.open.as_ref().expect("a block is open");
|
||||
|
||||
Reference in new issue
Block a user