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

+24 -4
View File
@@ -5,7 +5,11 @@ use std::ops::Range;
use gpui::{Context, Window};
use markdown::mdast;
use super::MarkdownDocument;
use super::{
MarkdownDocument,
cells::{Aim, Move, beside},
edit::Landing,
};
use crate::documents::markdown::{span, tree, walk};
/// Spaces one indent step adds.
@@ -196,7 +200,7 @@ impl MarkdownDocument {
/// Enter on a block list line; false leaves it.
pub(super) fn block_newline(&mut self, cx: &mut Context<Self>) -> bool {
let Some(open) = &self.open else {
let Some(open) = self.open.as_ref().filter(|open| open.cell.is_none()) else {
return false;
};
let input = open.input.clone();
@@ -218,11 +222,27 @@ impl MarkdownDocument {
true
}
/// Tab or Shift-Tab in the open block.
pub(super) fn block_shift(&mut self, deeper: bool, _: &mut Window, cx: &mut Context<Self>) {
/// Tab or Shift-Tab in the open block; in a cell, the next or previous.
pub(super) fn block_shift(
&mut self,
deeper: bool,
window: &mut Window,
cx: &mut Context<Self>,
) {
let Some(open) = &self.open else {
return;
};
if let Some(at) = open.cell {
let here = self.block_at(open.range.start);
let block = self.parsed.blocks[here].range.clone();
let by = if deeper { Move::Next } else { Move::Previous };
let text = self.editor.read(cx).text();
match beside(text, block, at, by) {
Some(to) => self.open(Some(here), Landing::Cell(Aim::At(to)), window, cx),
None => log::info!("markdown document: no cell {by:?} of {at:?}"),
}
return;
}
let input = open.input.clone();
let (text, selection) = {
let input = input.read(cx);