Merge pull request #584 from peco/gh-428

fix #428
This commit is contained in:
lestrrat 2026-02-15 14:10:22 +09:00 committed by GitHub
commit 8ecd1711e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 51 additions and 2 deletions

View file

@ -546,6 +546,8 @@ Note: If in case below keymap seems wrong, check the source code in [keymap.go](
|ArrowDown|peco.SelectDown|
|ArrowLeft|peco.ScrollPageUp|
|ArrowRight|peco.ScrollPageDown|
|Pgup|peco.ScrollPageUp|
|Pgdn|peco.ScrollPageDown|
## Styles

View file

@ -93,13 +93,13 @@ func init() {
ActionFunc(doSelectUp).Register("SelectUp", keyseq.KeyArrowUp, keyseq.KeyCtrlP)
wrapDeprecated(doSelectDown, "SelectNext", "SelectUp/SelectDown").Register("SelectNext")
ActionFunc(doScrollPageDown).Register("ScrollPageDown", keyseq.KeyArrowRight)
ActionFunc(doScrollPageDown).Register("ScrollPageDown", keyseq.KeyArrowRight, keyseq.KeyPgdn)
wrapDeprecated(doScrollPageDown, "SelectNextPage", "ScrollPageDown/ScrollPageUp").Register("SelectNextPage")
ActionFunc(doSelectDown).Register("SelectDown", keyseq.KeyArrowDown, keyseq.KeyCtrlN)
wrapDeprecated(doSelectUp, "SelectPrevious", "SelectUp/SelectDown").Register("SelectPrevious")
ActionFunc(doScrollPageUp).Register("ScrollPageUp", keyseq.KeyArrowLeft)
ActionFunc(doScrollPageUp).Register("ScrollPageUp", keyseq.KeyArrowLeft, keyseq.KeyPgup)
wrapDeprecated(doScrollPageUp, "SelectPreviousPage", "ScrollPageDown/ScrollPageUp").Register("SelectPreviousPage")
ActionFunc(doScrollLeft).Register("ScrollLeft")

View file

@ -525,3 +525,50 @@ func TestGHIssue574_PreviousSelectionLastLineNotUpdated(t *testing.T) {
"should jump to ID=20, the nearest previous selected line")
})
}
func TestGHIssue428_PgUpPgDnDefaultBindings(t *testing.T) {
// Issue #428: PgUp/PgDn keys should be bound by default to
// ScrollPageUp/ScrollPageDown, just like Home/End are bound
// to ScrollFirstItem/ScrollLastItem.
ctx := context.Background()
rHub := &recordingHub{}
state := New()
state.hub = rHub
state.selection = NewSelection()
state.currentLineBuffer = NewMemoryBuffer()
// Populate the keymap with defaults (no custom config).
state.config.Keymap = map[string]string{}
state.config.Action = map[string][]string{}
require.NoError(t, state.populateKeymap(), "populateKeymap should succeed")
km := state.Keymap()
t.Run("PgDn triggers ScrollPageDown", func(t *testing.T) {
rHub.reset()
ev := Event{Key: keyseq.KeyPgdn}
err := km.ExecuteAction(ctx, state, ev)
require.NoError(t, err, "PgDn should resolve to an action")
pagingArgs := rHub.getPagingArgs()
require.Len(t, pagingArgs, 1, "expected one paging call")
require.Equal(t, ToScrollPageDown, pagingArgs[0],
"PgDn should trigger ScrollPageDown")
})
t.Run("PgUp triggers ScrollPageUp", func(t *testing.T) {
rHub.reset()
ev := Event{Key: keyseq.KeyPgup}
err := km.ExecuteAction(ctx, state, ev)
require.NoError(t, err, "PgUp should resolve to an action")
pagingArgs := rHub.getPagingArgs()
require.Len(t, pagingArgs, 1, "expected one paging call")
require.Equal(t, ToScrollPageUp, pagingArgs[0],
"PgUp should trigger ScrollPageUp")
})
}