documents: presses read back through quotes, code, HTML and front matter

Each drawn character finds its written one, skipping only white
space, escapes and quote marks, so a press lands on the character
itself. Code, front matter and link definitions read back line for
line. An HTML block keeps each text run's source byte, and an alert
keeps its text past the marker; alert() now takes the source.

A secondary press refuses a target its write-back changed, and its
focus no longer opens an empty document. Run's element stack moves to
tree/stack.rs and the HTML-block reader to tree/html_block.rs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-14 10:11:00 -04:00
1 parent 5af11fe489
commit 83d747d87e
16 files changed
+868 -480

No files matched your search

+22 -7
View File
@@ -1,14 +1,15 @@
use gpui::{
AnyElement, App, ClickEvent, Context, ExternalPaths, FontWeight, InteractiveElement,
IntoElement, KeyBinding, MouseButton, MouseDownEvent, ParentElement, Render,
StatefulInteractiveElement, Styled, Window, actions, div, list, prelude::FluentBuilder as _,
StatefulInteractiveElement, Styled, StyledText, Window, actions, div, list,
prelude::FluentBuilder as _,
};
use super::{MarkdownDocument, edit::Landing};
use crate::{
documents::{
MarkdownMode,
render::{Hooks, Pointed, draw_nodes},
render::{Hooks, Pointed, draw_nodes, point_lines},
},
forms::{self, Down, Up},
primitives::FocusRing as _,
@@ -113,11 +114,25 @@ impl MarkdownDocument {
self.look.scale,
cx,
)),
None => div()
.text_size(body)
.font_family(mono)
.text_color(colors.fg_muted)
.child(self.parsed.text[block.range.clone()].to_string()),
None => {
let raw = &self.parsed.text[block.range.clone()];
let drawn = StyledText::new(raw.to_string());
let layout = drawn.layout().clone();
let shown = div()
.text_size(body)
.font_family(mono)
.text_color(colors.fg_muted)
.child(drawn)
.into_any_element();
div().child(point_lines(
shown,
layout,
raw,
0,
&on_point,
(false, false),
))
}
};
let block = div()
.id(("block", ix))