cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

History: a step's row heights allocated when a height changes

Dami committed b27d20b
An empty map for every step cost each edit an allocation; steps that
change no height leave it nil.
commit
b27d20b27a81a895fe6c38bcb4f2abc191f0ecc6
parent
3fd4dc903960cee7be21f4ffbe031f88efe4a8d6
author
Dami <dami.etoile@gmail.com>
kind
refactor risk score 1.2 of 3, Jev's estimate
2 files changed, +13 -5
Minternal/sheet/history.go8++++----
Minternal/sheet/rowlayout.go10+++++++++-
M internal/sheet/history.go +4 -4
@@ -41,7 +41,7 @@ type step struct {
4141 focus Rect // what the UI selects there4242 cells map[loc]*Cell // before the step; nil for blank4343 widths map[colKey]int // before the step; 0 for the default width44- heights map[rowKey]int // rows' heights before the step; 0 for none44+ heights map[rowKey]int // rows' heights before the step, 0 for none; nil until one changes4545 lines map[lineKey]lineFmt // column and row formats before the step4646 names map[string]*Name // before the step, by key; nil for undefined4747 views map[*Sheet]*viewState
@@ -68,7 +68,7 @@ type colKey struct {
6868 }6969 7070 func newStep(label string, s *Sheet, focus Rect) *step {71- return &step{label: label, sheet: s, focus: focus, cells: map[loc]*Cell{}, widths: map[colKey]int{}, heights: map[rowKey]int{}, lines: map[lineKey]lineFmt{},71+ return &step{label: label, sheet: s, focus: focus, cells: map[loc]*Cell{}, widths: map[colKey]int{}, lines: map[lineKey]lineFmt{},7272 names: map[string]*Name{}, views: map[*Sheet]*viewState{}, charts: map[*Sheet][]Chart{}, pivots: map[*Sheet]*Pivot{}, rules: map[*Sheet]rulesState{}}7373 }7474
@@ -281,7 +281,7 @@ func (h *history) joinWidths(top, st *step) {
281281 }282282 for k, h := range st.heights {283283 if _, ok := top.heights[k]; !ok {284- top.heights[k] = h284+ top.keepHeight(k, h)285285 }286286 }287287 top.dropUnchangedLines()
@@ -386,7 +386,7 @@ func (w *Workbook) swap(undo bool) (Change, bool) {
386386 k.s.setWidth(k.col, width)387387 }388388 for k, h := range st.heights {389- inv.heights[k] = k.s.heights[k.row]389+ inv.keepHeight(k, k.s.heights[k.row])390390 k.s.setHeight(k.row, h)391391 }392392 for k, l := range st.lines {
M internal/sheet/rowlayout.go +9 -1