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.
|
STARTCHARS: Possible chars for starting a commandline input.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, Qt
|
from PyQt5.QtCore import pyqtSlot, Qt
|
||||||
|
|
||||||
|
from qutebrowser.commands import cmdexc
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
from qutebrowser.keyinput import keyparser
|
from qutebrowser.keyinput import keyparser
|
||||||
from qutebrowser.utils import usertypes, log, objreg, utils
|
from qutebrowser.utils import usertypes, log, message, objreg, utils
|
||||||
|
|
||||||
|
|
||||||
STARTCHARS = ":/?"
|
STARTCHARS = ":/?"
|
||||||
@ -297,17 +300,20 @@ class RegisterKeyParser(keyparser.BaseKeyParser):
|
|||||||
window=self._win_id)
|
window=self._win_id)
|
||||||
macro_recorder = objreg.get('macro-recorder')
|
macro_recorder = objreg.get('macro-recorder')
|
||||||
|
|
||||||
if self._mode == usertypes.KeyMode.set_mark:
|
try:
|
||||||
tabbed_browser.set_mark(key)
|
if self._mode == usertypes.KeyMode.set_mark:
|
||||||
elif self._mode == usertypes.KeyMode.jump_mark:
|
tabbed_browser.set_mark(key)
|
||||||
tabbed_browser.jump_mark(key)
|
elif self._mode == usertypes.KeyMode.jump_mark:
|
||||||
elif self._mode == usertypes.KeyMode.record_macro:
|
tabbed_browser.jump_mark(key)
|
||||||
macro_recorder.record_macro(key)
|
elif self._mode == usertypes.KeyMode.record_macro:
|
||||||
elif self._mode == usertypes.KeyMode.run_macro:
|
macro_recorder.record_macro(key)
|
||||||
macro_recorder.run_macro(self._win_id, key)
|
elif self._mode == usertypes.KeyMode.run_macro:
|
||||||
else:
|
macro_recorder.run_macro(self._win_id, key)
|
||||||
raise ValueError(
|
else:
|
||||||
"{} is not a valid register key".format(self._mode))
|
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")
|
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
|
And I run :run-macro foo with count 2
|
||||||
Then the page should not be scrolled
|
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
|
## Variables
|
||||||
|
|
||||||
Scenario: {url} as part of an argument
|
Scenario: {url} as part of an argument
|
||||||
|
Loading…
Reference in New Issue
Block a user