v0.4.0 a622146

lsp_setting_test.go RawHistoryFolder

1package modes
2
3import (
4	"errors"
5	"strings"
6	"testing"
7)
8
9type failingLSPSettingsStore struct {
10	SettingsStore
11}
12
13func (failingLSPSettingsStore) SetLSPEnabled(bool) error {
14	return errors.New("persist lsp setting")
15}
16
17func (failingLSPSettingsStore) SetSubagentLSPEnabled(bool) error {
18	return errors.New("persist subagent lsp setting")
19}
20
21type rollbackFailingLSPSettingsStore struct {
22	SettingsStore
23	calls  int
24	values []bool
25}
26
27func (s *rollbackFailingLSPSettingsStore) SetLSPEnabled(enabled bool) error {
28	s.calls++
29	if s.calls == 2 {
30		return errors.New("rollback disk full")
31	}
32	s.values = append(s.values, enabled)
33	return nil
34}
35
36func (s *rollbackFailingLSPSettingsStore) SetSubagentLSPEnabled(bool) error {
37	return nil
38}
39
40func TestLSPSettingToggleKeepsMemoryOnPersistenceFailure(t *testing.T) {
41	mainEnabled := false
42	subagentEnabled := false
43	interactive := &Interactive{cfg: InteractiveConfig{
44		LSPEnabled:         &mainEnabled,
45		SubagentLSPEnabled: &subagentEnabled,
46		SettingsStore:      failingLSPSettingsStore{},
47	}}
48
49	interactive.applySettingToggle("lsp_enabled", true)
50	if *interactive.cfg.LSPEnabled {
51		t.Fatal("main-session LSP changed after persistence failure")
52	}
53	interactive.applySettingToggle("subagent_lsp_enabled", true)
54	if *interactive.cfg.SubagentLSPEnabled {
55		t.Fatal("sub-agent LSP changed after persistence failure")
56	}
57}
58
59func TestLSPSettingToggleKeepsDurableStateWhenRollbackPersistenceFails(t *testing.T) {
60	mainEnabled := true
61	store := &rollbackFailingLSPSettingsStore{}
62	refreshCalls := 0
63	interactive := NewInteractive(InteractiveConfig{
64		LSPEnabled:    &mainEnabled,
65		SettingsStore: store,
66		RefreshTools: func() error {
67			refreshCalls++
68			if refreshCalls == 1 {
69				return errors.New("refresh failed")
70			}
71			return nil
72		},
73	})
74	interactive.rend = nil
75
76	interactive.applySettingToggle("lsp_enabled", false)
77	if *interactive.cfg.LSPEnabled {
78		t.Fatal("in-memory LSP setting reverted despite rollback persistence failure")
79	}
80	if len(store.values) != 1 || store.values[0] {
81		t.Fatalf("durable writes = %v, want only the successful disable", store.values)
82	}
83	if refreshCalls != 2 {
84		t.Fatalf("refresh calls = %d, want failed refresh plus durable-state reconciliation", refreshCalls)
85	}
86	if !strings.Contains(interactive.statusErr, "rollback disk full") {
87		t.Fatalf("status error = %q, want rollback failure", interactive.statusErr)
88	}
89}

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 1

Tags 477

↑↓ moveenter openesc close