newedit/histlist: Cleanup.

This commit is contained in:
Qi Xiao 2019-04-24 21:48:52 +01:00
parent b7f11e6816
commit 5e41a4cd40
2 changed files with 4 additions and 6 deletions

View File

@ -23,14 +23,14 @@ func (m *Mode) Start(cmds []string) {
Name: "HISTLIST",
KeyHandler: m.KeyHandler,
ItemsGetter: func(p string) listing.Items {
return getEntries(cmds, p)
return getItems(cmds, p)
},
StartFilter: true,
})
}
// Given all commands, and a pattern, returning all matching entries.
func getEntries(cmds []string, p string) items {
func getItems(cmds []string, p string) items {
// TODO: Show the real in-storage IDs of cmds, not their in-memory indicies.
var entries []entry
for i, line := range cmds {

View File

@ -11,8 +11,6 @@ import (
var Args = tt.Args
var testCmds = []string{}
func TestGetEntries(t *testing.T) {
cmds := []string{
"put 1",
@ -21,7 +19,7 @@ func TestGetEntries(t *testing.T) {
"repr 4",
}
tt.Test(t, tt.Fn("getEntries", getEntries), tt.Table{
tt.Test(t, tt.Fn("getEntries", getItems), tt.Table{
// Show all commands.
Args(cmds, "").Rets(listing.MatchItems(
styled.Unstyled(" 1 put 1"),
@ -42,7 +40,7 @@ func TestAccept(t *testing.T) {
"put 1",
"echo 2",
}
entries := getEntries(cmds, "")
entries := getItems(cmds, "")
st := types.State{}
entries.Accept(0, &st)