nil_pty_test.go RawHistoryFolder

1package daemon
2
3import (
4	"context"
5	"io"
6	"log/slog"
7	"testing"
8
9	"github.com/stretchr/testify/require"
10
11	"github.com/bnema/vev/internal/domain"
12	"github.com/bnema/vev/internal/domain/layout"
13	"github.com/bnema/vev/internal/protocol"
14)
15
16func TestNilPTYLifecyclePathsDoNotPanic(t *testing.T) {
17	d := New(nil, nil, slog.New(slog.NewTextHandler(io.Discard, nil)))
18	ctx, cancel := context.WithCancel(context.Background())
19	defer cancel()
20	sess := &session{sessionCore: sessionCore{id: "s", name: "s"}, ctx: ctx, cancel: cancel}
21	d.sessions[sess.id] = sess
22	first := newTab(nil, domain.Size{Cols: 41, Rows: 10})
23	second := newTab(nil, domain.Size{Cols: 41, Rows: 10})
24	sess.tabs = []*tab{first, second}
25
26	first.mu.Lock()
27	first.size = domain.Size{Cols: 20, Rows: 5}
28	first.bumpLayoutGenerationLocked()
29	first.mu.Unlock()
30	require.NotPanics(t, func() {
31		sess.geometry.applyTabLayout(d, sess, first)
32	})
33	require.Equal(t, 20, first.focusedPane().screen.Columns())
34	require.Equal(t, 5, first.focusedPane().screen.Rows())
35
36	first.tree = &layout.Tree{Root: &layout.Node{Kind: layout.Split, Dir: layout.Horizontal, Children: []*layout.Node{layout.NewLeaf("pane-1"), layout.NewLeaf("pane-2")}}, Focus: "pane-2"}
37	first.panes["pane-2"] = newPane("pane-2", nil, domain.Size{Cols: 20, Rows: 10})
38	require.NotPanics(t, func() {
39		require.NoError(t, d.closePane(sess, first, "pane-2", nil, false))
40	})
41	require.NotContains(t, first.panes, layout.PaneID("pane-2"))
42
43	require.NotPanics(t, func() { require.NoError(t, d.closeTab(sess, second, false)) })
44	require.Len(t, sess.tabs, 1)
45}
46
47func TestKillSessionIgnoresNilPanePTYs(t *testing.T) {
48	d := New(nil, nil, slog.New(slog.NewTextHandler(io.Discard, nil)))
49	ctx, cancel := context.WithCancel(context.Background())
50	sess := &session{sessionCore: sessionCore{id: "s", name: "s", ephemeral: true}, ctx: ctx, cancel: cancel, tabs: []*tab{newTab(nil, domain.Size{Cols: 10, Rows: 3})}}
51	d.sessions[sess.id] = sess
52
53	require.NotPanics(t, func() {
54		require.NoError(t, d.killSession(sess, protocol.ReasonSessionKilled, true))
55	})
56	require.NotContains(t, d.sessions, sess.id)
57}
58
59func TestNilPTYInputPathsDoNotPanic(t *testing.T) {
60	d := New(nil, nil, slog.New(slog.NewTextHandler(io.Discard, nil)))
61	ctx, cancel := context.WithCancel(context.Background())
62	defer cancel()
63	tb := newTab(nil, domain.Size{Cols: 10, Rows: 3})
64	sess := &session{sessionCore: sessionCore{id: "s", name: "s"}, ctx: ctx, cancel: cancel, tabs: []*tab{tb}}
65	ac := &attachedClient{}
66	ac.initOverlays()
67	ac.setSession(sess)
68
69	require.NotPanics(t, func() { d.writeToPane(sess, tb.focusedPane(), []byte("x")) })
70	require.NotPanics(t, func() { daemonKeyHandler{d: d, ac: ac}.Forward([]byte("x")) })
71}

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 12

Tags 11

↑↓ moveenter openesc close