Merge remote-tracking branch 'origin/pr/3306'

This commit is contained in:
Florian Bruhin 2017-11-19 14:08:58 +01:00
commit 8c7bf12b88
2 changed files with 26 additions and 1 deletions

View File

@ -24,7 +24,7 @@ from PyQt5.QtWidgets import QSizePolicy
from qutebrowser.keyinput import modeman, modeparsers
from qutebrowser.commands import cmdexc, cmdutils
from qutebrowser.misc import cmdhistory
from qutebrowser.misc import cmdhistory, editor
from qutebrowser.misc import miscwidgets as misc
from qutebrowser.utils import usertypes, log, objreg
@ -166,6 +166,23 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
modeman.leave(self._win_id, usertypes.KeyMode.command, 'cmd accept')
self.got_cmd[str].emit(prefixes[text[0]] + text[1:])
@cmdutils.register(instance='status-command', scope='window')
def edit_command(self, run=False):
"""Open an editor to modify the current command.
Args:
run: Run the command if the editor exits successfully.
"""
ed = editor.ExternalEditor(parent=self)
def callback(text):
self.set_cmd_text(text)
if run:
self.got_cmd[str].emit(text)
ed.editing_finished.connect(callback)
ed.edit(self.text())
@pyqtSlot(usertypes.KeyMode)
def on_mode_left(self, mode):
"""Clear up when command mode was left.

View File

@ -141,3 +141,11 @@ Feature: Opening external editors
And I wait for "Read back: bar" in the log
And I run :click-element id qute-button
Then the javascript message "text: bar" should be logged
## :edit-command
Scenario: Edit a command and run it
When I run :set-cmd-text :message-info foo
And I set up a fake editor replacing "foo" by "bar"
And I run :edit-command --run
Then the message "bar" should be shown