v0.3.68 a98ca1a

clipboard_windows_test.go RawHistoryFolder

1//go:build windows
2
3package tui
4
5import (
6	"errors"
7	"slices"
8	"testing"
9)
10
11func TestReadWindowsClipboardImagePNGUsesSTAAndNormalizes(t *testing.T) {
12	var gotName string
13	var gotArgs []string
14	run := func(name string, _ int, args ...string) ([]byte, error) {
15		gotName = name
16		gotArgs = append([]string(nil), args...)
17		return testClipboardPNG(t), nil
18	}
19
20	path, data, ok, err := readWindowsClipboardImagePNG(run)
21	if err != nil {
22		t.Fatal(err)
23	}
24	if path != "" || !ok || len(data) == 0 {
25		t.Fatalf("path = %q, ok = %v, len(data) = %d", path, ok, len(data))
26	}
27	if gotName != "powershell.exe" {
28		t.Fatalf("command = %q, want powershell.exe", gotName)
29	}
30	if !slices.Contains(gotArgs, "-STA") {
31		t.Fatalf("PowerShell args do not enable STA: %q", gotArgs)
32	}
33}
34
35func TestReadWindowsClipboardImagePNGTriesPwshFallback(t *testing.T) {
36	var commands []string
37	run := func(name string, _ int, _ ...string) ([]byte, error) {
38		commands = append(commands, name)
39		if name == "powershell.exe" {
40			return nil, errors.New("Windows PowerShell failed")
41		}
42		return testClipboardPNG(t), nil
43	}
44
45	_, _, ok, err := readWindowsClipboardImagePNG(run)
46	if err != nil || !ok {
47		t.Fatalf("ok = %v, err = %v", ok, err)
48	}
49	if !slices.Equal(commands, []string{"powershell.exe", "pwsh.exe"}) {
50		t.Fatalf("commands = %q", commands)
51	}
52}
53
54func TestReadWindowsClipboardImagePNGRejectsMalformedData(t *testing.T) {
55	run := func(string, int, ...string) ([]byte, error) {
56		return []byte("not an image"), nil
57	}
58	if _, _, ok, err := readWindowsClipboardImagePNG(run); err == nil || ok {
59		t.Fatalf("ok = %v, err = %v", ok, err)
60	}
61}

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 476

↑↓ moveenter openesc close