Merge pull request #149 from nihilist-narwhal/fix-table-header-edits

Tables: typing in the header row renames the column; Go To a table selects its data

# Conflicts:
#	crates/engine/src/tables.rs
This commit is contained in:
Brandon Thomas
2026-10-10 15:47:10 -04:00
3 changed files with 148 additions and 4 deletions
+2 -1
View File
@@ -478,7 +478,8 @@ fn go_to(s: &mut Session, p: &Json) -> Result<Json> {
if let Some(n) = d.wb.name(reference, sheet) {
n.formula.clone()
} else if let Some((si, ti)) = d.wb.table(reference) {
let t = d.wb.sheet(si).and_then(|sh| sh.tables.get(ti)).map(|t| t.range.a1()).unwrap_or_default();
// As in Excel, a table's name stands for its data, without the header and totals rows.
let t = d.wb.sheet(si).and_then(|sh| sh.tables.get(ti)).map(|t| t.data_range().unwrap_or(t.range).a1()).unwrap_or_default();
format!("'{}'!{}", d.wb.sheet(si).map(|s| s.name.clone()).unwrap_or_default(), t)
} else {
return Err(EngineError::Other("Reference isn't valid.".into()));
+5 -1
View File
@@ -240,7 +240,11 @@ pub struct Ctx<'a> {
pub(crate) fn edit<R>(s: &mut Session, f: impl FnOnce(&mut Ctx) -> Result<R>) -> Result<R> {
let d = s.doc_mut()?;
commit(d, f)
commit(d, |cx| {
let r = f(cx)?;
crate::tables::sync_headers(cx);
Ok(r)
})
}
pub(crate) fn commit<R>(d: &mut DocState, f: impl FnOnce(&mut Ctx) -> Result<R>) -> Result<R> {