โ– humdrum codex / glint v1.0.2
license AGPL-3.0
2.1 KB raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package picker

import (
	"os"
	"path/filepath"
	"strings"
	"testing"

	"glint/internal/theme"

	"github.com/charmbracelet/lipgloss"
)

// Long vault-relative paths must not wrap in the list column: a wrapped label
// inflates the rendered height past the viewport and scrolls the query field
// (top line) off-screen. Every rendered line must fit the terminal width.
func TestListLabelsDoNotWrapOrOverflow(t *testing.T) {
	root := t.TempDir()
	names := []string{
		"short.md",
		"Meetings/2026-06-18 Weekly Project Sync Notes and Review.md",
		"Issues/tracker/task-003 - schedule-nightly-backup-and-rotate-old-snapshots-cron-job.md",
		"Working Files/Reference Material (longer parenthetical title here).md",
	}
	// Plus enough files to overfill the viewport โ€” the real-world trigger is a
	// vault of hundreds of notes, where a single wrapped label pushes the query
	// field off the top.
	for i := 0; i < 80; i++ {
		names = append(names, filepath.Join("ARCHER/Meetings",
			"2026-06-18 ARCHER ABE Team Meeting Review long filler "+strings.Repeat("x", 30)+".md"))
	}
	for i, n := range names {
		// de-dup the filler names so they are distinct files
		if i >= 4 {
			n = strings.Replace(n, "filler ", "filler"+string(rune('a'+i%26))+" ", 1)
		}
		p := filepath.Join(root, n)
		if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
			t.Fatal(err)
		}
		if err := os.WriteFile(p, []byte("# x\n"), 0o644); err != nil {
			t.Fatal(err)
		}
	}

	for _, dims := range [][2]int{{120, 30}, {80, 24}, {50, 20}} {
		m, err := New(root, theme.FlexokiDark(), "", "dark")
		if err != nil {
			t.Fatal(err)
		}
		m.SetSize(dims[0], dims[1]-1) // app gives the picker height-1

		out := m.View()
		lines := strings.Split(out, "\n")

		if !strings.Contains(lines[0], "note") {
			t.Errorf("dims=%v: query field not on the first line; got %q", dims, lines[0])
		}
		for i, ln := range lines {
			if w := lipgloss.Width(ln); w > dims[0] {
				t.Errorf("dims=%v: line %d width %d exceeds terminal width %d (will wrap): %q",
					dims, i, w, dims[0], ln)
			}
		}
		if len(lines) > dims[1] {
			t.Errorf("dims=%v: picker view has %d lines, exceeds terminal height %d", dims, len(lines), dims[1])
		}
	}
}