Ensuring comliance of partial forwarding feature with unit tests
This commit is contained in:
parent
2956c5f2c3
commit
47dc51fda9
|
|
@ -199,7 +199,7 @@ class BaseKeyParser(QObject):
|
|||
self._pure_sequence = keyutils.KeySequence()
|
||||
self._sequence = keyutils.KeySequence()
|
||||
self._count = ''
|
||||
self._count_keyposs = []
|
||||
self._count_keyposs: Sequence[int] = []
|
||||
self._mode = mode
|
||||
self._do_log = do_log
|
||||
self.passthrough = passthrough
|
||||
|
|
@ -310,8 +310,10 @@ class BaseKeyParser(QObject):
|
|||
|
||||
self._debug_log(f"Got key: {info!r} (dry_run {dry_run})")
|
||||
|
||||
# Modifier keys handled in modeman
|
||||
assert not keyutils.is_modifier_key(key)
|
||||
# Modifier keys should be previously handled by modeman
|
||||
if keyutils.is_modifier_key(key):
|
||||
self._debug_log("Ignoring, only modifier")
|
||||
return QKeySequence.SequenceMatch.NoMatch
|
||||
|
||||
had_empty_queue = (not self._pure_sequence) and (not self._count)
|
||||
|
||||
|
|
@ -455,7 +457,9 @@ class BaseKeyParser(QObject):
|
|||
|
||||
def clear_keystring(self) -> None:
|
||||
"""Clear the currently entered key sequence."""
|
||||
do_emit = False
|
||||
if self._count:
|
||||
do_emit = True
|
||||
self._debug_log("Clearing keystring count (was: {}).".format(
|
||||
self._count))
|
||||
self._count = ''
|
||||
|
|
@ -463,8 +467,10 @@ class BaseKeyParser(QObject):
|
|||
# self._pure_sequence should non-empty if and only if self._sequence is
|
||||
# non-empty, but to be safe both conditions are included below
|
||||
if self._pure_sequence or self._sequence:
|
||||
do_emit = True
|
||||
self._debug_log("Clearing keystring (was: {}).".format(
|
||||
self._sequence))
|
||||
self._pure_sequence = keyutils.KeySequence()
|
||||
self._sequence = keyutils.KeySequence()
|
||||
self.keystring_updated.emit('')
|
||||
if do_emit:
|
||||
self.keystring_updated.emit('')
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ handle what we actually think we do.
|
|||
import itertools
|
||||
import dataclasses
|
||||
from typing import Optional, Union, overload, cast, Tuple
|
||||
from collections.abc import Iterator, Iterable, Mapping
|
||||
from collections.abc import Iterator, Iterable, Mapping, Sequence
|
||||
|
||||
from qutebrowser.qt import machinery
|
||||
from qutebrowser.qt.core import Qt, QEvent
|
||||
|
|
@ -545,7 +545,7 @@ class QueuedKeyEventPair:
|
|||
|
||||
key_event: KeyEvent
|
||||
key_info_press: KeyInfo
|
||||
key_info_release: KeyInfo
|
||||
key_info_release: Union[KeyInfo, None]
|
||||
|
||||
@classmethod
|
||||
def from_event_press(cls, event: QKeyEvent) -> 'QueuedKeyEventPair':
|
||||
|
|
@ -562,7 +562,7 @@ class QueuedKeyEventPair:
|
|||
def is_released(self) -> bool:
|
||||
return self.key_info_release is not None
|
||||
|
||||
def to_events(self) -> Tuple[QKeyEvent]:
|
||||
def to_events(self) -> Sequence[QKeyEvent]:
|
||||
"""Get a QKeyEvent from this QueuedEvent."""
|
||||
if self.key_info_release is None:
|
||||
return (self.key_info_press.to_event(QEvent.KeyPress),)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ from PyQt5.QtWidgets import QApplication
|
|||
|
||||
import functools
|
||||
import dataclasses
|
||||
from typing import Union, cast, Tuple
|
||||
from collections.abc import Mapping, MutableMapping, Callable
|
||||
from typing import Union, cast
|
||||
from collections.abc import Mapping, MutableMapping, Callable, Sequence
|
||||
|
||||
from qutebrowser.qt import machinery
|
||||
from qutebrowser.qt.core import pyqtSlot, pyqtSignal, Qt, QObject, QEvent
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class FakeKeyparser(QObject):
|
|||
super().__init__()
|
||||
self.passthrough = False
|
||||
self.allow_partial_timeout = False
|
||||
self.allow_forward = True
|
||||
self.forward_widget_name = None
|
||||
|
||||
def handle(
|
||||
self,
|
||||
|
|
@ -72,6 +74,8 @@ class FakeKeyparserWithTimeout(QObject):
|
|||
super().__init__()
|
||||
self.passthrough = False
|
||||
self.allow_partial_timeout = True
|
||||
self.allow_forward = True
|
||||
self.forward_widget_name = None
|
||||
self.fake_clear_keystring_called = False
|
||||
|
||||
def handle(self, evt, *, dry_run=False):
|
||||
|
|
|
|||
Loading…
Reference in New Issue