- commit
- 07daf2026e056aadd000ffcb8c934cb7b32848b0
- parent
- ed043839dc34e4e4919630485d3ce9205518a7ea
- author
- Dami <dami.etoile@gmail.com>
| M | e2e/ | 14 | +++++++++++ |
| A | e2e/ | 30 | ++++++++++++++++++++++++ |
| M | internal/ | 37 | +++++++++++++++++++++++++++--- |
| A | internal/ | 34 | ++++++++++++++++++++++++++++ |
@@ -16,6 +16,19 @@ func hideSummary(s *session) {
1616 s.waitFor("Hid Summary")1717 }1818 19+// traceHidden hides Sheet1 and traces the precedents of Summary!B1,20+// which reads only Sheet1.21+func traceHidden(s *session) {22+ summary(s)23+ s.click(ghostty.MouseButtonRight, tabX(s.t, s, "Sheet1"), int(s.rows)-1)24+ s.waitFor("Hide sheet")25+ s.keys("<down>", "<down>", "<down>", "<enter>")26+ s.waitFor("Hid Sheet1")27+ s.waitForBar("B1", "=Sheet1!B7*12")28+ s.keys("<alt+,>")29+ s.waitFor("Reads only Sheet1, a hidden sheet; View > Hidden sheets shows it")30+}31+1932 // importLocation opens the import location picker for budget.tsv on a2033 // spreadsheet with something in it.2134 func importLocation(s *session) {@@ -40,6 +53,7 @@ var sheetScreens = []screen{
4053 s.keys("<enter>")4154 s.waitFor("1 of 1")4255 }},56+ {name: "trace-hidden", setup: traceHidden},4357 {name: "autocomplete-sheet", setup: func(s *session) {4458 summary(s)4559 s.keys("<ctrl+pgup>", "<down>", "<down>", "<down>", "=B7/sum")@@ -0,0 +1,30 @@
1+<pre class="screen"> <span style="text-decoration:underline">F</span>ile <span style="text-decoration:underline">E</span>dit <span style="text-decoration:underline">V</span>iew <span style="text-decoration:underline">I</span>nsert F<span style="text-decoration:underline">o</span>rmat <span style="text-decoration:underline">D</span>ata <span style="text-decoration:underline">H</span>elp <span style="background:var(--vt-palette-6)"> </span><span style="color:var(--vt-palette-0);background:var(--vt-palette-6);font-weight:bold">READY</span><span style="background:var(--vt-palette-6)"> </span>2+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">B1</span><span style="background:var(--vt-palette-8)"> </span> =Sheet1!B7*123+Reads only Sheet1, a hidden sheet; View > Hidden sheets shows it4+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">A</span><span style="background:var(--vt-palette-8)"> </span><span style="background:var(--vt-palette-6)"> </span><span style="color:var(--vt-palette-0);background:var(--vt-palette-6);font-weight:bold">B</span><span style="background:var(--vt-palette-6)"> </span><span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">C</span><span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">D</span><span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">E</span><span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">F</span><span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">G</span><span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">H</span><span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">I</span><span style="background:var(--vt-palette-8)"> </span>5+<span style="background:var(--vt-palette-6)"> </span><span style="color:var(--vt-palette-0);background:var(--vt-palette-6);font-weight:bold">1</span><span style="background:var(--vt-palette-6)"> </span> Yearly to<span style="background:var(--vt-palette-6)"> </span><span style="color:var(--vt-palette-0);background:var(--vt-palette-6)">25900.8</span><span style="background:var(--vt-palette-6)"> </span>6+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">2</span><span style="background:var(--vt-palette-8)"> </span> Monthly 719.466677+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">3</span><span style="background:var(--vt-palette-8)"> </span>8+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">4</span><span style="background:var(--vt-palette-8)"> </span>9+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">5</span><span style="background:var(--vt-palette-8)"> </span>10+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">6</span><span style="background:var(--vt-palette-8)"> </span>11+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">7</span><span style="background:var(--vt-palette-8)"> </span>12+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">8</span><span style="background:var(--vt-palette-8)"> </span>13+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">9</span><span style="background:var(--vt-palette-8)"> </span>14+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">10</span><span style="background:var(--vt-palette-8)"> </span>15+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">11</span><span style="background:var(--vt-palette-8)"> </span>16+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">12</span><span style="background:var(--vt-palette-8)"> </span>17+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">13</span><span style="background:var(--vt-palette-8)"> </span>18+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">14</span><span style="background:var(--vt-palette-8)"> </span>19+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">15</span><span style="background:var(--vt-palette-8)"> </span>20+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">16</span><span style="background:var(--vt-palette-8)"> </span>21+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">17</span><span style="background:var(--vt-palette-8)"> </span>22+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">18</span><span style="background:var(--vt-palette-8)"> </span>23+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">19</span><span style="background:var(--vt-palette-8)"> </span>24+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">20</span><span style="background:var(--vt-palette-8)"> </span>25+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">21</span><span style="background:var(--vt-palette-8)"> </span>26+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">22</span><span style="background:var(--vt-palette-8)"> </span>27+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">23</span><span style="background:var(--vt-palette-8)"> </span>28+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">24</span><span style="background:var(--vt-palette-8)"> </span>29+<span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">25</span><span style="background:var(--vt-palette-8)"> </span>30+<span style="background:var(--vt-palette-6)"> </span><span style="color:var(--vt-palette-0);background:var(--vt-palette-6);font-weight:bold">Summary</span><span style="background:var(--vt-palette-6)"> </span> <span style="color:var(--vt-palette-8)">+</span> <span style="color:var(--vt-palette-8)">│</span> untitled <span style="color:var(--vt-palette-8)">modified</span> <span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">Ctrl+K</span><span style="background:var(--vt-palette-8)"> </span> <span style="color:var(--vt-palette-8)">search</span> <span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">Ctrl+/</span><span style="background:var(--vt-palette-8)"> </span> <span style="color:var(--vt-palette-8)">shortcuts</span> <span style="background:var(--vt-palette-8)"> </span><span style="color:var(--vt-palette-15);background:var(--vt-palette-8)">F10</span><span style="background:var(--vt-palette-8)"> </span> <span style="color:var(--vt-palette-8)">menu</span></pre>\ No newline at end of file@@ -55,13 +55,11 @@ func (m *Model) stepTrace(dependents bool) {
5555 t.targets = m.sheet.Precedents(m.cur)5656 }5757 // Cells on hidden sheets can't be shown, so the trace skips them.58+ hidden := hiddenSheets(t.targets)5859 t.targets = slices.DeleteFunc(t.targets, func(tg sheet.Target) bool { return tg.Sheet.Hidden() })5960 if len(t.targets) == 0 {6061 m.trace = nil61- m.note = "No formulas read " + m.cur.String()62- if !dependents {63- m.note = m.cur.String() + " has no formula reading other cells"64- }62+ m.note = noTrace(dependents, m.cur, hidden)6563 return6664 }6765 m.trace = t@@ -72,6 +70,37 @@ func (m *Model) stepTrace(dependents bool) {
7270 m.cur = t.targets[t.at].Range.From7371 }7472 73+// hiddenSheets names the hidden sheets targets are on, in order.74+func hiddenSheets(targets []sheet.Target) []string {75+ var out []string76+ for _, tg := range targets {77+ if tg.Sheet.Hidden() && !slices.Contains(out, tg.Sheet.Name()) {78+ out = append(out, tg.Sheet.Name())79+ }80+ }81+ return out82+}83+84+// noTrace says why a trace from a found nothing to show: nothing to85+// find, or only cells on hidden sheets, which it names.86+func noTrace(dependents bool, a sheet.Addr, hidden []string) string {87+ if len(hidden) == 0 {88+ if dependents {89+ return "No formulas read " + a.String()90+ }91+ return a.String() + " has no formula reading other cells"92+ }93+ names, what, it := hidden[0], "a hidden sheet", "it"94+ if n := len(hidden); n > 1 {95+ names = strings.Join(hidden[:n-1], ", ") + " and " + hidden[n-1]96+ what, it = "hidden sheets", "them"97+ }98+ if dependents {99+ return "Only formulas on " + names + ", " + what + ", read " + a.String() + "; View > Hidden sheets shows " + it100+ }101+ return "Reads only " + names + ", " + what + "; View > Hidden sheets shows " + it102+}103+75104 // traceKey ends the trace on any key but the trace commands, and returns76105 // to the traced cell on Esc. It reports whether it used the key.77106 func (m *Model) traceKey(k tea.KeyPressMsg) bool {@@ -0,0 +1,34 @@
1+package ui2+3+import "testing"4+5+// Tracing a formula whose every precedent is on a hidden sheet says so,6+// and where to show it; the same for dependents.7+func TestTraceIntoHiddenSheet(t *testing.T) {8+ m := hiddenBook(t)9+ run(m, m.runCommand("sheet.hide"))10+ press(t, m, "<ctrl+pgup>")11+ m.cur = addr("A1")12+ press(t, m, "<alt+,>")13+ if got := line(m, contextLine); m.trace != nil || got != "Reads only Data, a hidden sheet; View > Hidden sheets shows it" {14+ t.Errorf("trace %v, context %q", m.trace, got)15+ }16+ m.book().Lookup("Sheet3").Set(addr("B2"), "5")17+ m.book().HideSheet(m.book().Lookup("Sheet3"))18+ m.sheet.Set(addr("A2"), "=Data!A1+Sheet3!B2")19+ m.cur = addr("A2")20+ press(t, m, "<alt+,>")21+ if got := line(m, contextLine); got != "Reads only Data and Sheet3, hidden sheets; View > Hidden sheets shows them" {22+ t.Errorf("context %q", got)23+ }24+ // Precedents on a sheet shown are traced as ever.25+ m.sheet.Set(addr("A3"), "=Data!A1+A2")26+ m.cur = addr("A3")27+ press(t, m, "<alt+,>")28+ if m.trace == nil || m.cur != addr("A2") {29+ t.Errorf("trace %v, on %v", m.trace, m.cur)30+ }31+ if got := noTrace(true, addr("B2"), []string{"Data"}); got != "Only formulas on Data, a hidden sheet, read B2; View > Hidden sheets shows it" {32+ t.Errorf("dependents: %q", got)33+ }34+}