main 5041353

vim_mode_policy.go RawHistoryFolder

1package usecase
2
3// VimModePolicyTransition describes what the UI should do after a Vim mode
4// policy evaluation.
5type VimModePolicyTransition string
6
7const (
8	VimModePolicyTransitionStay VimModePolicyTransition = "stay"
9	VimModePolicyTransitionExit VimModePolicyTransition = "exit"
10)
11
12// VimModePolicyTrigger identifies the focus or activation event being
13// evaluated.
14type VimModePolicyTrigger string
15
16const (
17	VimModePolicyTriggerActivationAttempt        VimModePolicyTrigger = "activation_attempt"
18	VimModePolicyTriggerOmniboxFocus             VimModePolicyTrigger = "omnibox_focus"
19	VimModePolicyTriggerFindBarFocus             VimModePolicyTrigger = "find_bar_focus"
20	VimModePolicyTriggerOverlayFocus             VimModePolicyTrigger = "overlay_focus"
21	VimModePolicyTriggerPageEditableFocusChanged VimModePolicyTrigger = "page_editable_focus_changed"
22	VimModePolicyTriggerContextChanged           VimModePolicyTrigger = "context_changed"
23)
24
25// VimModePolicyInput captures the current Vim mode state and the event being
26// evaluated.
27type VimModePolicyInput struct {
28	Trigger                 VimModePolicyTrigger
29	VimModeActive           bool
30	PageEditableFocused     bool
31	EventInActiveContext    bool
32	PreserveOnContextChange bool
33}
34
35// VimModePolicyUseCase evaluates whether Vim mode should stay active, exit,
36// or be blocked from activating.
37type VimModePolicyUseCase struct{}
38
39// NewVimModePolicyUseCase creates a VimModePolicyUseCase.
40func NewVimModePolicyUseCase() *VimModePolicyUseCase {
41	return &VimModePolicyUseCase{}
42}
43
44// Evaluate decides the Vim mode transition for the provided event.
45func (*VimModePolicyUseCase) Evaluate(input VimModePolicyInput) VimModePolicyTransition {
46	switch input.Trigger {
47	case VimModePolicyTriggerActivationAttempt:
48		// Ctrl+Y is the explicit Vim Mode activation command. It must remain
49		// available while a page input is focused so users can leave typing mode
50		// without first moving focus elsewhere.
51		return VimModePolicyTransitionStay
52	case VimModePolicyTriggerOmniboxFocus,
53		VimModePolicyTriggerFindBarFocus,
54		VimModePolicyTriggerOverlayFocus:
55		if input.VimModeActive {
56			return VimModePolicyTransitionExit
57		}
58		return VimModePolicyTransitionStay
59	case VimModePolicyTriggerPageEditableFocusChanged:
60		if input.VimModeActive && input.PageEditableFocused && input.EventInActiveContext {
61			return VimModePolicyTransitionExit
62		}
63		return VimModePolicyTransitionStay
64	case VimModePolicyTriggerContextChanged:
65		if input.VimModeActive && !input.PreserveOnContextChange {
66			return VimModePolicyTransitionExit
67		}
68		return VimModePolicyTransitionStay
69	default:
70		return VimModePolicyTransitionStay
71	}
72}

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