@@ -95,12 +95,14 @@ func (h *InfoPane) HandleEvent(event tcell.Event) {
9595 done := h .DoKeyEvent (ke )
9696 hasYN := h .HasYN
9797 if e .Key () == tcell .KeyRune && hasYN {
98- if (e .Rune () == 'y' || e .Rune () == 'Y' ) && hasYN {
99- h .YNResp = true
100- h .DonePrompt (false )
101- } else if (e .Rune () == 'n' || e .Rune () == 'N' ) && hasYN {
102- h .YNResp = false
98+ y := e .Rune () == 'y' || e .Rune () == 'Y'
99+ n := e .Rune () == 'n' || e .Rune () == 'N'
100+ if y || n {
101+ h .YNResp = y
103102 h .DonePrompt (false )
103+
104+ InfoBindings .ResetEvents ()
105+ InfoBufBindings .ResetEvents ()
104106 }
105107 }
106108 if e .Key () == tcell .KeyRune && ! done && ! hasYN {
@@ -124,7 +126,10 @@ func (h *InfoPane) HandleEvent(event tcell.Event) {
124126 }
125127}
126128
127- // DoKeyEvent executes a key event for the command bar, doing any overridden actions
129+ // DoKeyEvent executes a key event for the command bar, doing any overridden actions.
130+ // Returns true if the action was executed OR if there are more keys remaining
131+ // to process before executing an action (if this is a key sequence event).
132+ // Returns false if no action found.
128133func (h * InfoPane ) DoKeyEvent (e KeyEvent ) bool {
129134 action , more := InfoBindings .NextEvent (e , nil )
130135 if action != nil && ! more {
@@ -138,11 +143,25 @@ func (h *InfoPane) DoKeyEvent(e KeyEvent) bool {
138143 }
139144
140145 if ! more {
146+ // If no infopane action found, try to find a bufpane action.
147+ //
148+ // TODO: this is buggy. For example, if the command bar has the following
149+ // two bindings:
150+ //
151+ // "<Ctrl-x><Ctrl-p>": "HistoryUp",
152+ // "<Ctrl-x><Ctrl-v>": "Paste",
153+ //
154+ // the 2nd binding (with a bufpane action) doesn't work, since <Ctrl-x>
155+ // has been already consumed by the 1st binding (with an infopane action).
156+ //
157+ // We should either iterate both InfoBindings and InfoBufBindings keytrees
158+ // together, or just use the same keytree for both infopane and bufpane
159+ // bindings.
141160 action , more = InfoBufBindings .NextEvent (e , nil )
142161 if action != nil && ! more {
143- done := action (h .BufPane )
162+ action (h .BufPane )
144163 InfoBufBindings .ResetEvents ()
145- return done
164+ return true
146165 } else if action == nil && ! more {
147166 InfoBufBindings .ResetEvents ()
148167 }
0 commit comments