Documents: a press in a table opens its cell alone
CI / platforms (windows-latest) (push) Failing after 10s
CI / site (push) Successful in 23s
CI / crate (push) Failing after 11m56s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

Visual mode opened a pressed table whole, as Markdown source. A press
in a table now opens only that cell, in place, as its source in a
one-line field; the rest of the table stays drawn. Tab and Shift-Tab
walk the cells, Up and Down move a row or leave the table, Enter and
Escape write back in one undo step, and a bare pipe typed in a cell is
escaped on write-back. The table drawing moves to render/table.rs and
presses on a cell's padding name the cell.

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-15 00:50:20 -04:00
1 parent 991ca7b548
commit 2594b3fd0f
14 files changed
+591 -106

No files matched your search

+12 -5
View File
@@ -3,7 +3,9 @@ use std::rc::Rc;
use gpui::{AppContext as _, Context, MouseButton, Pixels, Point, Window};
use markdown::mdast;
use super::{DocumentEvent, MarkdownDocument, edit::Landing, edit::moved, parse::Block};
use super::{
DocumentEvent, MarkdownDocument, cells::Aim, edit::Landing, edit::moved, parse::Block,
};
use crate::documents::{
markdown::{file_tree, span, walk},
render::{OnPoint, Place, Pointed},
@@ -80,15 +82,20 @@ impl MarkdownDocument {
Some(lines_at(&parsed.text[start..], *from, text, *at).unwrap_or(*from))
}
Place::At(at) => Some(*at),
Place::Block => None,
Place::Cell(_) | Place::Block => None,
}
.map(|at| start + at);
// A press in a table opens only its cell.
let landing = match (&pointed.place, at) {
(Place::Cell(cell), _) => Landing::Cell(Aim::At(*cell)),
(_, Some(at)) if pointed.table => Landing::Cell(Aim::Byte(at)),
(_, Some(at)) => Landing::At(at),
(_, None) => Landing::End,
};
let ix = Some(ix);
document
.update(cx, |document, cx| match button {
MouseButton::Left => {
document.open(ix, at.map_or(Landing::End, Landing::At), window, cx)
}
MouseButton::Left => document.open(ix, landing, window, cx),
MouseButton::Right => document.point(ix, at, pointed, window, cx),
_ => {}
})