- commit
- a18133cab31326de2b142dd781ab32c5b89910bd
- parent
- 7867877752abf7090e8040089877a694219ff3be
- author
- Dami <dami.etoile@gmail.com>
- kind
- fix risk score 1.2 of 3, Jev's estimate
| M | internal/ | 7 | +++++-- |
| M | internal/ | 26 | ++++++++++++++++++++++++++ |
@@ -89,9 +89,12 @@ func (g *grid) scrollRows() int {
8989 func (g *grid) bands() []band {9090 n := g.visibleRows()9191 out := make([]band, 0, n)92- y := gridTop92+ y, shaped := gridTop, g.sheet.Shaped()9393 add := func(r int) bool {94- sh := g.shape(r)94+ sh := rowtext.Shape{Lines: 1}95+ if shaped {96+ sh = g.shape(r)97+ }9598 b := band{row: r, y: y, rule: sh.Rule, lines: sh.Lines}9699 b.shown = min(sh.Lines, gridTop+n-b.top())97100 if b.shown <= 0 {@@ -301,3 +301,29 @@ func TestRecordRowHeightDrag(t *testing.T) {
301301 t.Errorf("replayed height %d (%q)", h, r.warn)302302 }303303 }304+305+// A chart floats over the rows it's anchored to, however tall they are,306+// and dragging it snaps its corner to the row under the mouse.307+func TestChartOverTallRows(t *testing.T) {308+ m := newModel()309+ m.sheet.AddChart(sheet.Chart{Type: sheet.ChartColumn, Data: rect("A1:B3"), At: addr("D5"), W: 20, H: 8})310+ m.sheet.SetRowHeight(1, 1, 4) // row 2 is four lines tall311+ c := m.sheet.Charts()[0]312+ _, y := m.chartScreen(c)313+ if want, _ := m.rowY(4); y != want {314+ t.Errorf("chart at line %d, row 5 at %d", y, want)315+ }316+ if got := m.chartCellAt(0, y); got.Row != 4 {317+ t.Errorf("line %d is row %d", y, got.Row+1)318+ }319+ if got := m.chartCellAt(0, gridTop+2); got.Row != 1 {320+ t.Errorf("the third line is row %d, want 2", got.Row+1)321+ }322+ m.top = 3 // scrolled past the tall row: the chart's lines follow323+ if _, y := m.chartScreen(c); y != gridTop+1 {324+ t.Errorf("scrolled: chart at line %d", y)325+ }326+ if _, y := m.chartScreen(sheet.Chart{At: addr("D2"), H: 8}); y != gridTop-5 {327+ t.Errorf("above the top: chart at line %d", y)328+ }329+}