summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2018-09-30 11:45:59 +0200
committerFlorian Bruhin <me@the-compiler.org>2018-09-30 11:45:59 +0200
commit96f28c6f724b81a900ae4c849ba489e3e4e29f6d (patch)
tree4ba5fef34100ba12f56a4a8d951d44ddf12373a8
parentd362299e4ee0751b7df0f32d15387cca033d788e (diff)
downloadqutebrowser-96f28c6f724b81a900ae4c849ba489e3e4e29f6d.tar.gz
qutebrowser-96f28c6f724b81a900ae4c849ba489e3e4e29f6d.zip
Show errors on invalid --mode argument for :hint
-rw-r--r--doc/changelog.asciidoc1
-rw-r--r--qutebrowser/browser/hints.py8
-rw-r--r--tests/end2end/features/hints.feature4
3 files changed, 12 insertions, 1 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index 70274a591..1e554452b 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -93,6 +93,7 @@ Fixed
be shown for more files such as `qute://help/userscripts.html`.
- Crash when doing initial run on Wayland without XWayland
- Crash when trying to load an empty session file.
+- `:hint` with an invalid `--mode=` value now shows a proper error.
Removed
~~~~~~~
diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py
index 00481c2f4..333999356 100644
--- a/qutebrowser/browser/hints.py
+++ b/qutebrowser/browser/hints.py
@@ -32,7 +32,7 @@ import attr
from PyQt5.QtCore import pyqtSlot, QObject, Qt, QUrl
from PyQt5.QtWidgets import QLabel
-from qutebrowser.config import config
+from qutebrowser.config import config, configexc
from qutebrowser.keyinput import modeman, modeparsers
from qutebrowser.browser import webelem
from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners
@@ -726,6 +726,12 @@ class HintManager(QObject):
if mode is None:
mode = config.val.hints.mode
+ else:
+ opt = config.instance.get_opt('hints.mode')
+ try:
+ opt.typ.to_py(mode)
+ except configexc.ValidationError as e:
+ raise cmdexc.CommandError("Invalid mode: {}".format(e))
self._check_args(target, *args)
self._context = HintContext()
diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature
index 3a0cb1da0..fd4465daa 100644
--- a/tests/end2end/features/hints.feature
+++ b/tests/end2end/features/hints.feature
@@ -15,6 +15,10 @@ Feature: Using hints
And I hint with args "links normal" and follow xyz
Then the error "No hint xyz!" should be shown
+ Scenario: Using :hint with invalid mode.
+ When I run :hint --mode=foobar
+ Then the error "Invalid mode: Invalid value 'foobar' - valid values: number, letter, word" should be shown
+
### Opening in current or new tab
Scenario: Following a hint and force to open in current tab.