mirror of
https://github.com/zaphar/sheetsui.git
synced 2025-07-22 04:39:48 -04:00
wip: fix area calculation bug
This commit is contained in:
parent
8dd6f6d614
commit
e798350cd2
@ -227,13 +227,7 @@ impl Book {
|
||||
}
|
||||
|
||||
pub fn clear_cell_range(&mut self, sheet: u32, start: Address, end: Address) -> Result<()> {
|
||||
let area = Area {
|
||||
sheet,
|
||||
row: start.row as i32,
|
||||
column: start.col as i32,
|
||||
width: (end.row - start.row) as i32,
|
||||
height: (end.col - end.row) as i32,
|
||||
};
|
||||
let area = calculate_area(sheet, start, end);
|
||||
self.model
|
||||
.range_clear_contents(&area)
|
||||
.map_err(|s| anyhow!("Unable to clear cell contents {}", s))?;
|
||||
@ -254,13 +248,7 @@ impl Book {
|
||||
}
|
||||
|
||||
pub fn clear_cell_range_all(&mut self, sheet: u32, start: Address, end: Address) -> Result<()> {
|
||||
let area = Area {
|
||||
sheet,
|
||||
row: start.row as i32,
|
||||
column: start.col as i32,
|
||||
width: (end.row - start.row) as i32,
|
||||
height: (end.col - end.row) as i32,
|
||||
};
|
||||
let area = calculate_area(sheet, start, end);
|
||||
self.model.range_clear_all(&area)
|
||||
.map_err(|s| anyhow!("Unable to clear cell contents {}", s))?;
|
||||
Ok(())
|
||||
@ -584,6 +572,17 @@ impl Book {
|
||||
}
|
||||
}
|
||||
|
||||
fn calculate_area(sheet: u32, start: Address, end: Address) -> Area {
|
||||
let area = Area {
|
||||
sheet,
|
||||
row: start.row as i32,
|
||||
column: start.col as i32,
|
||||
height: (end.row - start.row + 1) as i32,
|
||||
width: (end.col - start.col + 1) as i32,
|
||||
};
|
||||
area
|
||||
}
|
||||
|
||||
impl Default for Book {
|
||||
fn default() -> Self {
|
||||
let mut book =
|
||||
|
@ -131,7 +131,7 @@ impl<'ws> AppState<'ws> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(jwall): This should probably move to a different module.
|
||||
// TODO(jwall): Should we just be using `Area` for this?.
|
||||
/// The Address in a Table.
|
||||
#[derive(Debug, PartialEq, PartialOrd, Ord, Eq, Clone)]
|
||||
pub struct Address {
|
||||
@ -539,7 +539,7 @@ impl<'ws> Workspace<'ws> {
|
||||
self.handle_numeric_prefix(d);
|
||||
}
|
||||
KeyCode::Char('D') => {
|
||||
if let Some((start, end)) = self.state.range_select.get_range() {
|
||||
if let Some((start, end)) = dbg!(self.state.range_select.get_range()) {
|
||||
self.book.clear_cell_range_all(
|
||||
self.state
|
||||
.range_select
|
||||
|
Loading…
x
Reference in New Issue
Block a user