diff --git a/Changes b/Changes index e238168..47bc44b 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,9 @@ v0.6.0 - UNRELEASED `CustomMatcher`. Use `InitialFilter` and `CustomFilter` instead. * Removed deprecated CLI option `--initial-matcher`. Use `--initial-filter` instead. + * The action `ViewArround` has been renamed to `ViewAround` (fix typo). + The old name still works but shows a deprecation notice. If you have + `"ViewArround"` in your config, please update it to `"ViewAround"`. v0.5.11 - 21 Mar 2023 [Features] diff --git a/action.go b/action.go index 204380c..3bc1ed5 100644 --- a/action.go +++ b/action.go @@ -150,7 +150,8 @@ func init() { ActionFunc(doRefreshScreen).Register("RefreshScreen", keyseq.KeyCtrlL) ActionFunc(doToggleSingleKeyJump).Register("ToggleSingleKeyJump") - ActionFunc(doToggleViewArround).Register("ViewArround", keyseq.KeyCtrlV) + ActionFunc(doToggleViewAround).Register("ViewAround", keyseq.KeyCtrlV) + wrapDeprecated(doToggleViewAround, "ViewArround", "ViewAround").Register("ViewArround") ActionFunc(doFreezeResults).Register("FreezeResults") ActionFunc(doUnfreezeResults).Register("UnfreezeResults") @@ -744,9 +745,9 @@ func doToggleSingleKeyJump(ctx context.Context, state *Peco, e Event) { state.ToggleSingleKeyJumpMode(ctx) } -func doToggleViewArround(ctx context.Context, state *Peco, e Event) { +func doToggleViewAround(ctx context.Context, state *Peco, e Event) { if pdebug.Enabled { - g := pdebug.Marker("doToggleViewArround") + g := pdebug.Marker("doToggleViewAround") defer g.End() } q := state.Query() diff --git a/action_test.go b/action_test.go index 6f87ef5..f5200b1 100644 --- a/action_test.go +++ b/action_test.go @@ -163,6 +163,16 @@ func TestActionNames(t *testing.T) { } } +func TestViewAroundActionName(t *testing.T) { + // The correct spelling "ViewAround" must be registered. + _, ok := nameToActions["peco.ViewAround"] + require.True(t, ok, "peco.ViewAround must be registered as an action name") + + // The old misspelled name "ViewArround" must also work for backward compatibility. + _, ok = nameToActions["peco.ViewArround"] + require.True(t, ok, "peco.ViewArround must remain registered for backward compatibility") +} + func expectCaretPos(t *testing.T, c *Caret, expect int) bool { return assert.Equal(t, expect, c.Pos(), "Expected caret position %d, got %d", expect, c.Pos()) }