diff --git a/main.go b/main.go index 40882fc..d623c16 100644 --- a/main.go +++ b/main.go @@ -21,9 +21,10 @@ func main() { println(cell.Value.(int)) ss.UpdateCell(cell00.Uuid, `15`) - println(cell.Value.(int)) + println(`Cell00 value is now:`, cell00.Value.(int)) + println(`Cell value is now:`, cell.Value.(int)) cell03, _ := ss.GetCell("Sheet1", 0, 3) - ss.UpdateCell(cell03.Uuid, `=Min(A1:C4)`) + ss.UpdateCell(cell03.Uuid, `=Sum(A1:C4)`) println(cell03.Value.(int)) } diff --git a/src/core/computation.go b/src/core/computation.go index 97ffaba..4c63a93 100644 --- a/src/core/computation.go +++ b/src/core/computation.go @@ -104,7 +104,7 @@ func (cell *Cell) dirty(visited mapset.Set[ReferenceId]) error { ss.RangeDirtyParents[currRange.Uuid] = mapset.NewThreadUnsafeSet[ReferenceId]() } // Tracks the cells that need to be recomputed before recomputing the range. - ss.RangeDirtyParents[cell.Uuid].Add(currRange.Uuid) + ss.RangeDirtyParents[currRange.Uuid].Add(cell.Uuid) } // Dirty all dependent cells. @@ -152,8 +152,8 @@ func (ss *Spreadsheet) recomputeValues() { Cell: currCell, }) currCell.Value, currCell.Error = res, err - currCell.Value = res } + ss.DirtySet.Clear() } func (ss *Spreadsheet) cleanupRanges() { diff --git a/src/core/read.go b/src/core/read.go index eda7d6a..4202910 100644 --- a/src/core/read.go +++ b/src/core/read.go @@ -75,7 +75,7 @@ func (cr *Range) GetUuid() ReferenceId { } func (cr *Range) LowAtDimension(dimension uint64) int64 { - if dimension == 0 { + if dimension == 1 { return int64(cr.StartRow) } else { return int64(cr.StartCol) @@ -83,7 +83,7 @@ func (cr *Range) LowAtDimension(dimension uint64) int64 { } func (cr *Range) HighAtDimension(dimension uint64) int64 { - if dimension == 0 { + if dimension == 1 { return int64(cr.EndRow) } else { return int64(cr.EndCol) @@ -91,10 +91,10 @@ func (cr *Range) HighAtDimension(dimension uint64) int64 { } func (cr *Range) OverlapsAtDimension(interval augmentedtree.Interval, dimension uint64) bool { - if dimension == 0 { - return int64(cr.StartRow) <= interval.HighAtDimension(uint64(dimension)) && int64(cr.EndRow) >= interval.LowAtDimension(uint64(dimension)) + if dimension == 1 { + return int64(cr.StartRow) <= interval.HighAtDimension(dimension) && int64(cr.EndRow) >= interval.LowAtDimension(dimension) } else { - return int64(cr.StartCol) <= interval.HighAtDimension(uint64(dimension)) && int64(cr.EndCol) <= interval.LowAtDimension(uint64(dimension)) + return int64(cr.StartCol) <= interval.HighAtDimension(dimension) && int64(cr.EndCol) >= interval.LowAtDimension(dimension) } }