Filter: a table filter must reach the table's last data row, and the table part keeps only such filters

This commit is contained in:
Harrison Booth committed 2026-10-27 16:20:32 -05:00
1 parent db21e558d1
commit 0b31398c0d
2 files changed
+9 -2

No files matched your search

+3
View File
@@ -75,6 +75,9 @@ fn install_filter(s: &mut Session, p: &Json) -> Result<Json> {
}
// A narrower range would leave out the table's criteria on the columns it doesn't cover, and saving would drop them.
if let Some(t) = host.and_then(|i| sh.tables.get(i)) {
if t.data_range().is_some_and(|data| r.end.row < data.end.row) {
return Err(bad("data.filter", "filter the table's full data range"));
}
let shift = r.start.col.saturating_sub(t.range.start.col);
if t.filter.iter().any(|(o, _)| o.checked_sub(shift).is_none_or(|c| c >= r.width())) {
return Err(bad("data.filter", "the table is filtered on a column this range leaves out; filter the table's full width"));
+6 -2
View File
@@ -107,8 +107,12 @@ pub(super) fn autofilter_xml(range: RangeRef, criteria: &[(u32, FilterCriterion)
/// as rows hidden by hand, which SUBTOTAL 1-11 counts.
pub(super) fn table_filter(sheet: &Sheet, t: &Table) -> Vec<(u32, FilterCriterion)> {
let mut criteria = t.filter.clone();
let Some(af) = sheet.autofilter.as_ref().filter(|af| t.header_row && af.range.start.row == t.range.start.row && af.range.intersects(&t.range))
else {
let Some(af) = sheet.autofilter.as_ref().filter(|af| {
t.header_row
&& af.range.start.row == t.range.start.row
&& af.range.intersects(&t.range)
&& t.data_range().is_some_and(|d| af.range.end.row >= d.end.row)
}) else {
return criteria;
};
for (off, c) in &af.criteria {