Handle ² keypress correctly
Turns out str.isdigit() also handles ² as a digit, but int('²') causes a ValueError. Here we use `string.digits` instead, which is '0123456789'. Fixes #3743
This commit is contained in:
parent
db1287cb82
commit
29ad252278
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
"""Base class for vim-like key sequence parser."""
|
"""Base class for vim-like key sequence parser."""
|
||||||
|
|
||||||
|
import string
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, QObject
|
from PyQt5.QtCore import pyqtSignal, QObject
|
||||||
from PyQt5.QtGui import QKeySequence
|
from PyQt5.QtGui import QKeySequence
|
||||||
|
|
||||||
@ -136,7 +138,7 @@ class BaseKeyParser(QObject):
|
|||||||
def _match_count(self, sequence, dry_run):
|
def _match_count(self, sequence, dry_run):
|
||||||
"""Try to match a key as count."""
|
"""Try to match a key as count."""
|
||||||
txt = str(sequence[-1]) # To account for sequences changed above.
|
txt = str(sequence[-1]) # To account for sequences changed above.
|
||||||
if (txt.isdigit() and self._supports_count and
|
if (txt in string.digits and self._supports_count and
|
||||||
not (not self._count and txt == '0')):
|
not (not self._count and txt == '0')):
|
||||||
self._debug_log("Trying match as count")
|
self._debug_log("Trying match as count")
|
||||||
assert len(txt) == 1, txt
|
assert len(txt) == 1, txt
|
||||||
|
@ -320,6 +320,10 @@ class TestCount:
|
|||||||
keyparser.execute.assert_called_once_with('message-info ccc', 23)
|
keyparser.execute.assert_called_once_with('message-info ccc', 23)
|
||||||
assert not keyparser._sequence
|
assert not keyparser._sequence
|
||||||
|
|
||||||
|
def test_superscript(self, handle_text, keyparser):
|
||||||
|
# https://github.com/qutebrowser/qutebrowser/issues/3743
|
||||||
|
handle_text(Qt.Key_twosuperior, Qt.Key_B, Qt.Key_A)
|
||||||
|
|
||||||
def test_count_keystring_update(self, qtbot, handle_text, keyparser):
|
def test_count_keystring_update(self, qtbot, handle_text, keyparser):
|
||||||
"""Make sure the keystring is updated correctly when entering count."""
|
"""Make sure the keystring is updated correctly when entering count."""
|
||||||
with qtbot.waitSignals([keyparser.keystring_updated,
|
with qtbot.waitSignals([keyparser.keystring_updated,
|
||||||
|
Loading…
Reference in New Issue
Block a user