Catch RegisterKeyParser command errors
This commit is contained in:
parent
f2b05a0395
commit
21289a80ad
@ -23,11 +23,14 @@ Module attributes:
|
||||
STARTCHARS: Possible chars for starting a commandline input.
|
||||
"""
|
||||
|
||||
import traceback
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, Qt
|
||||
|
||||
from qutebrowser.commands import cmdexc
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.keyinput import keyparser
|
||||
from qutebrowser.utils import usertypes, log, objreg, utils
|
||||
from qutebrowser.utils import usertypes, log, message, objreg, utils
|
||||
|
||||
|
||||
STARTCHARS = ":/?"
|
||||
@ -297,17 +300,20 @@ class RegisterKeyParser(keyparser.BaseKeyParser):
|
||||
window=self._win_id)
|
||||
macro_recorder = objreg.get('macro-recorder')
|
||||
|
||||
if self._mode == usertypes.KeyMode.set_mark:
|
||||
tabbed_browser.set_mark(key)
|
||||
elif self._mode == usertypes.KeyMode.jump_mark:
|
||||
tabbed_browser.jump_mark(key)
|
||||
elif self._mode == usertypes.KeyMode.record_macro:
|
||||
macro_recorder.record_macro(key)
|
||||
elif self._mode == usertypes.KeyMode.run_macro:
|
||||
macro_recorder.run_macro(self._win_id, key)
|
||||
else:
|
||||
raise ValueError(
|
||||
"{} is not a valid register key".format(self._mode))
|
||||
try:
|
||||
if self._mode == usertypes.KeyMode.set_mark:
|
||||
tabbed_browser.set_mark(key)
|
||||
elif self._mode == usertypes.KeyMode.jump_mark:
|
||||
tabbed_browser.jump_mark(key)
|
||||
elif self._mode == usertypes.KeyMode.record_macro:
|
||||
macro_recorder.record_macro(key)
|
||||
elif self._mode == usertypes.KeyMode.run_macro:
|
||||
macro_recorder.run_macro(self._win_id, key)
|
||||
else:
|
||||
raise ValueError(
|
||||
"{} is not a valid register key".format(self._mode))
|
||||
except (cmdexc.CommandMetaError, cmdexc.CommandError) as err:
|
||||
message.error(str(err), stack=traceback.format_exc())
|
||||
|
||||
self.request_leave.emit(self._mode, "valid register key")
|
||||
|
||||
|
@ -648,6 +648,21 @@ Feature: Various utility commands.
|
||||
And I run :run-macro foo with count 2
|
||||
Then the page should not be scrolled
|
||||
|
||||
Scenario: Running an invalid macro
|
||||
Given I open data/scroll/simple.html
|
||||
And I run :tab-only
|
||||
When I run :run-macro
|
||||
And I press the key "b"
|
||||
Then the error "No macro recorded in 'b'!" should be shown
|
||||
And no crash should happen
|
||||
|
||||
Scenario: Running an invalid named macro
|
||||
Given I open data/scroll/simple.html
|
||||
And I run :tab-only
|
||||
When I run :run-macro bar
|
||||
Then the error "No macro recorded in 'bar'!" should be shown
|
||||
And no crash should happen
|
||||
|
||||
## Variables
|
||||
|
||||
Scenario: {url} as part of an argument
|
||||
|
Loading…
Reference in New Issue
Block a user