Fix broken alias view

mine
derailed 2019-02-26 06:37:41 -08:00
parent fcd2611547
commit 668bc063ef
1 changed files with 16 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package views
import (
"context"
"fmt"
"sort"
"strings"
"github.com/derailed/k9s/internal/resource"
@ -16,7 +17,6 @@ const (
type aliasView struct {
*tableView
current igniter
}
@ -26,12 +26,18 @@ func newAliasView(app *appView) *aliasView {
v.SetSelectedStyle(tcell.ColorWhite, tcell.ColorFuchsia, tcell.AttrNone)
v.colorerFn = aliasColorer
v.current = app.content.GetPrimitive("main").(igniter)
v.sortFn = v.sorterFn
}
v.actions[tcell.KeyEnter] = newKeyAction("Search", v.aliasCmd)
v.actions[tcell.KeyEscape] = newKeyAction("Reset", v.resetCmd)
v.actions[KeySlash] = newKeyAction("Filter", v.activateCmd)
return &v
}
func (v *aliasView) sorterFn(ss []string) {
sort.Strings(ss)
}
// Init the view.
func (v *aliasView) init(context.Context, string) {
v.update(v.hydrate())
@ -43,6 +49,15 @@ func (v *aliasView) getTitle() string {
return aliasTitle
}
func (v *aliasView) resetCmd(evt *tcell.EventKey) *tcell.EventKey {
if !v.cmdBuff.empty() {
v.cmdBuff.reset()
v.refresh()
return nil
}
return v.backCmd(evt)
}
func (v *aliasView) aliasCmd(evt *tcell.EventKey) *tcell.EventKey {
if v.cmdBuff.isActive() {
return v.filterCmd(evt)