Better dig key handling

pull/275/head
Anton Medvedev 9 months ago
parent 0b6ab660a3
commit 1f977869fc
No known key found for this signature in database

@ -53,11 +53,11 @@ func init() {
key.WithHelp("", "half page down"),
),
GotoTop: key.NewBinding(
key.WithKeys("g"),
key.WithKeys("g", "home"),
key.WithHelp("", "goto top"),
),
GotoBottom: key.NewBinding(
key.WithKeys("G"),
key.WithKeys("G", "end"),
key.WithHelp("", "goto bottom"),
),
Down: key.NewBinding(

@ -247,7 +247,24 @@ func (m *model) handleDigKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
}
}
case key.Matches(msg, key.NewBinding(key.WithKeys("ctrl+w"))):
digPath, ok := jsonpath.Split(m.digInput.Value())
if ok {
digPath = digPath[:len(digPath)-1]
n := m.selectByPath(digPath)
if n != nil {
m.selectNode(n)
m.digInput.SetValue(m.cursorPath())
m.digInput.CursorEnd()
}
}
default:
if key.Matches(msg, key.NewBinding(key.WithKeys("."))) {
m.digInput.SetValue(m.cursorPath())
m.digInput.CursorEnd()
}
m.digInput, cmd = m.digInput.Update(msg)
n := m.dig(m.digInput.Value())
if n != nil {

Loading…
Cancel
Save