Skip to content

Commit

Permalink
fix raw mode
Browse files Browse the repository at this point in the history
pressing enter in raw mode did still execute history entry from normal mode
very dangerous, very embarassing
  • Loading branch information
curusarn committed May 17, 2020
1 parent fe878c5 commit ec302f5
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,37 @@ 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
}

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
}
Expand Down

0 comments on commit ec302f5

Please sign in to comment.