Fix prompts while in command mode

This commit is contained in:
Florian Bruhin 2016-11-04 06:47:56 +01:00
parent dd0ce8fe3b
commit a16d41333b
2 changed files with 31 additions and 18 deletions

View File

@ -201,8 +201,12 @@ class PromptQueue(QObject):
@pyqtSlot(usertypes.KeyMode) @pyqtSlot(usertypes.KeyMode)
def _on_mode_left(self, mode): def _on_mode_left(self, mode):
"""Abort question when a mode was left.""" """Abort question when a prompt mode was left."""
if self._question is not None: if mode not in [usertypes.KeyMode.prompt, usertypes.KeyMode.yesno]:
return
if self._question is None:
return
log.prompt.debug("Left mode {}, hiding {}".format( log.prompt.debug("Left mode {}, hiding {}".format(
mode, self._question)) mode, self._question))
self.show_prompts.emit(None) self.show_prompts.emit(None)
@ -332,7 +336,8 @@ class PromptContainer(QWidget):
This ensures no matter where a prompt was answered, we leave the prompt This ensures no matter where a prompt was answered, we leave the prompt
mode and dispose of the prompt object in every window. mode and dispose of the prompt object in every window.
""" """
if mode in [usertypes.KeyMode.prompt, usertypes.KeyMode.yesno]: if mode not in [usertypes.KeyMode.prompt, usertypes.KeyMode.yesno]:
return
modeman.maybe_leave(self._win_id, mode, 'left in other window') modeman.maybe_leave(self._win_id, mode, 'left in other window')
item = self._layout.takeAt(0) item = self._layout.takeAt(0)
if item is not None: if item is not None:

View File

@ -419,3 +419,11 @@ Feature: Prompts
And I run :prompt-item-focus next And I run :prompt-item-focus next
And I run :prompt-accept test-prompt-item-focus And I run :prompt-accept test-prompt-item-focus
Then "Added quickmark test-prompt-item-focus for *" should be logged Then "Added quickmark test-prompt-item-focus for *" should be logged
Scenario: Getting question in command mode
When I open data/hello.txt
And I run :later 500 quickmark-save
And I run :set-cmd-text :
And I wait for a prompt
And I run :prompt-accept prompt-in-command-mode
Then "Added quickmark prompt-in-command-mode for *" should be logged