From ec302f55f612c1a0fbdd8564966222a1338d7f61 Mon Sep 17 00:00:00 2001 From: Simon Let Date: Sun, 17 May 2020 17:51:11 +0200 Subject: [PATCH] fix raw mode pressing enter in raw mode did still execute history entry from normal mode very dangerous, very embarassing --- cmd/cli/main.go | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 6870c46..1578643 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -200,10 +200,18 @@ type manager struct { func (m manager) SelectExecute(g *gocui.Gui, v *gocui.View) error { m.s.lock.Lock() defer m.s.lock.Unlock() - if m.s.highlightedItem < len(m.s.data) { - m.s.output = m.s.data[m.s.highlightedItem].CmdLine - m.s.exitCode = exitCodeExecute - return gocui.ErrQuit + if m.s.rawMode { + if m.s.highlightedItem < len(m.s.rawData) { + m.s.output = m.s.rawData[m.s.highlightedItem].CmdLine + m.s.exitCode = exitCodeExecute + return gocui.ErrQuit + } + } else { + if m.s.highlightedItem < len(m.s.data) { + m.s.output = m.s.data[m.s.highlightedItem].CmdLine + m.s.exitCode = exitCodeExecute + return gocui.ErrQuit + } } return nil } @@ -211,10 +219,18 @@ func (m manager) SelectExecute(g *gocui.Gui, v *gocui.View) error { func (m manager) SelectPaste(g *gocui.Gui, v *gocui.View) error { m.s.lock.Lock() defer m.s.lock.Unlock() - if m.s.highlightedItem < len(m.s.data) { - m.s.output = m.s.data[m.s.highlightedItem].CmdLine - m.s.exitCode = 0 // success - return gocui.ErrQuit + if m.s.rawMode { + if m.s.highlightedItem < len(m.s.rawData) { + m.s.output = m.s.rawData[m.s.highlightedItem].CmdLine + m.s.exitCode = 0 // success + return gocui.ErrQuit + } + } else { + if m.s.highlightedItem < len(m.s.data) { + m.s.output = m.s.data[m.s.highlightedItem].CmdLine + m.s.exitCode = 0 // success + return gocui.ErrQuit + } } return nil }