v0.30.0 eb3068f

writer_test.go RawHistoryFolder

1package config
2
3import (
4	"os"
5	"path/filepath"
6	"strings"
7	"testing"
8)
9
10func TestWriteConfigOrdered(t *testing.T) {
11	// Create a temp directory for the test
12	tmpDir := t.TempDir()
13	configPath := filepath.Join(tmpDir, "config.toml")
14
15	// Get default config
16	cfg := DefaultConfig()
17
18	// Write it
19	err := WriteConfigOrdered(cfg, configPath)
20	if err != nil {
21		t.Fatalf("WriteConfigOrdered failed: %v", err)
22	}
23
24	// Read back
25	content, err := os.ReadFile(configPath)
26	if err != nil {
27		t.Fatalf("Failed to read written config: %v", err)
28	}
29
30	// Verify sections are in alphabetical order
31	lines := strings.Split(string(content), "\n")
32	var sections []string
33	for _, line := range lines {
34		if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") {
35			sections = append(sections, line)
36		}
37	}
38
39	// Check that sections are sorted
40	for i := 1; i < len(sections); i++ {
41		if sections[i-1] > sections[i] {
42			t.Errorf("Sections not sorted: %s > %s", sections[i-1], sections[i])
43		}
44	}
45
46	t.Logf("Found %d sections, all sorted", len(sections))
47
48	// Print first 50 lines for debugging
49	t.Logf("First 50 lines of output:\n%s", strings.Join(lines[:min(50, len(lines))], "\n"))
50}
51
52func TestSortTOMLSections(t *testing.T) {
53	input := `default_search_engine = 'https://example.com'
54
55[workspace]
56new_pane_url = 'about:blank'
57
58[appearance]
59color_scheme = 'default'
60
61[workspace.pane_mode]
62timeout_ms = 3000
63
64[appearance.dark_palette]
65background = '#000'
66`
67
68	result := sortTOMLSections(input)
69
70	// Extract section order
71	lines := strings.Split(result, "\n")
72	var sections []string
73	for _, line := range lines {
74		if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") {
75			sections = append(sections, line)
76		}
77	}
78
79	// Expected order: appearance, appearance.dark_palette, workspace, workspace.pane_mode
80	expected := []string{
81		"[appearance]",
82		"[appearance.dark_palette]",
83		"[workspace]",
84		"[workspace.pane_mode]",
85	}
86
87	if len(sections) != len(expected) {
88		t.Fatalf("Expected %d sections, got %d: %v", len(expected), len(sections), sections)
89	}
90
91	for i, exp := range expected {
92		if sections[i] != exp {
93			t.Errorf("Section %d: expected %s, got %s", i, exp, sections[i])
94		}
95	}
96
97	t.Logf("Sorted output:\n%s", result)
98}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close