mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 09:57:51 +08:00
newedit/histlist: Cleanup.
This commit is contained in:
parent
b7f11e6816
commit
5e41a4cd40
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user