- commit
- a461650d8b83a2ca71b1452905c455bad2f58cb1
- parent
- e1a9129696d95a16fe40673b6a98e7aa7555a32e
- author
- Dami <dami.etoile@gmail.com>
- kind
- chore risk score 1.3 of 3, Jev's estimate
| M | docs/ | 2 | +- |
| M | docs/ | 2 | +- |
| M | internal/ | 27 | ++++++++++++++++++--------- |
| M | internal/ | 13 | ------------- |
| M | internal/ | 2 | +- |
| M | internal/ | 1 | + |
@@ -212,7 +212,7 @@ and its cells in `notebookCells`, one per line:
212212 ```213213 214214 - `kind` is `note` for Markdown, left out for code; `source` is what the215- cell holds, a code cell's name and all (`files = ls`).215+ cell holds, a code cell's name and all, as `files` above.216216 - `output` is what the cell's last run printed, as NUON text, kept when217217 it fits the `nu-save-cell-kb` and `nu-save-notebook-kb` caps218218 ([Configuration](../reference/config.md#nushell-notebooks)); `unsaved`@@ -19,7 +19,7 @@ in a notebook, its cells' outputs live parts of the sheets.
1919 | Way | Looks like | For |2020 |---|---|---|2121 | [A stage in a pipeline](pipelines.md) | `ls \| sheet \| where size > 1kb` | Looking at a table on the terminal, editing it, and sending it on to the next command |22-| [A notebook](notebooks.md) | `sheet nu`, then `files = ls \| select name size` in a code cell | Pipelines you keep, as in Jupyter: cells run when you ask, each output under its cell, read by later cells as `$files` and, sent to a sheet, by formulas and charts |22+| [A notebook](notebooks.md) | `sheet nu`, then `ls \| select name size` in a code cell named `files` | Pipelines you keep, as in Jupyter: cells run when you ask, each output under its cell, read by later cells as `$files` and, sent to a sheet, by formulas and charts |2323 | [A followed file](../files/following.md) | Data > Linked file, then `$app \| where status >= 500` | A log or export that keeps growing: its rows come in as they're written, and pipelines read the rows it has now |2424 2525 ```mermaid@@ -201,15 +201,6 @@ func TestKeysDocCoversKeymap(t *testing.T) {
201201 t.Errorf("docs/reference/keys.md doesn't list %s (%s, %s)", label, id, commands[id].title)202202 }203203 }204- for _, keys := range []map[string]string{nbKeys, nbEditKeys} {205- for k, id := range keys {206- label := nbview.KeyLabel(k)207- re := regexp.MustCompile("(^|[\\s,|(/`])" + regexp.QuoteMeta(label) + "($|[\\s,|)/.;:`])")208- if commands[id] == nil || !re.MatchString(doc) {209- t.Errorf("docs/reference/keys.md doesn't list the notebook's %s (%s)", label, id)210- }211- }212- }213204 var vimKeys []string214205 for _, table := range []map[string]vimBinding{vimNormal, vimVisual} {215206 for k := range table {@@ -231,3 +222,21 @@ func TestKeysDocCoversKeymap(t *testing.T) {
231222 }232223 }233224 }225+226+// TestKeysDocCoversNotebookKeys checks docs/reference/keys.md lists the227+// notebook's keys, as the notebook shows them.228+func TestKeysDocCoversNotebookKeys(t *testing.T) {229+ data, err := os.ReadFile("../../docs/reference/keys.md")230+ if err != nil {231+ t.Fatal(err)232+ }233+ for _, keys := range []map[string]string{nbKeys, nbEditKeys} {234+ for k, id := range keys {235+ label := nbview.KeyLabel(k)236+ re := regexp.MustCompile("(^|[\\s,|(/`])" + regexp.QuoteMeta(label) + "($|[\\s,|)/.;:`])")237+ if commands[id] == nil || !re.MatchString(string(data)) {238+ t.Errorf("docs/reference/keys.md doesn't list the notebook's %s (%s)", label, id)239+ }240+ }241+ }242+}@@ -34,19 +34,6 @@ type lineCtx struct {
3434 merges []sheet.Rect // merges crossing the row3535 }3636 37-// labelSpans are the label lines of regions on a row.38-type labelSpans []sheet.Rect39-40-// Contains reports whether a is on one of them.41-func (l labelSpans) Contains(a sheet.Addr) bool {42- for _, r := range l {43- if r.Contains(a) {44- return true45- }46- }47- return false48-}49-5037 func (m *Model) lineContext(row int, ln rowtext.Line) lineCtx {5138 lc := lineCtx{row: row, ln: ln, focus: m.active(), shaped: m.sheet.Shaped()}5239 lc.sel, lc.selecting = m.highlight()@@ -135,7 +135,7 @@ func (m *Model) notebookBar(v *nbview.View) string {
135135 func (m *Model) notebookFormulaBar(v *nbview.View) string {136136 name, text := v.Head()137137 box := m.th.Header.Render(theme.PadRight(" "+ansi.Truncate(name, nameBoxW-1, "…"), nameBoxW)) + " "138- return box + m.th.Muted.Render(text)138+ return box + m.th.Muted.Render(ansi.Truncate(text, max(m.width-nameBoxW-1, 1), "…"))139139 }140140 141141 // pasteMsg takes pasted text: into a notebook's cell being edited, and@@ -285,6 +285,7 @@ func (v *View) headLine(i int, c notebook.Cell) string {
285285 th := v.h.Theme()286286 left, right := v.headText(c)287287 w := max(v.width-1, 1)288+ left = ansi.Truncate(left, w, "…") // a long name on a narrow screen288289 right = ansi.Truncate(right, max(w-ansi.StringWidth(left)-2, 0), "…")289290 text := left + strings.Repeat(" ", max(w-ansi.StringWidth(left)-ansi.StringWidth(right), 1)) + right290291 switch {