Show keyhint even with count prefix.
The keyhintwidget was not showing up when a keychain was prefixed with a count. For example, 'g' would show a keyhint but '5g' would not. Now keyhints are shown even when a count is given. Resolves #3045.
This commit is contained in:
parent
5af8a95c82
commit
5d787c84ea
@ -26,6 +26,7 @@ It is intended to help discoverability of keybindings.
|
|||||||
|
|
||||||
import html
|
import html
|
||||||
import fnmatch
|
import fnmatch
|
||||||
|
import re
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QLabel, QSizePolicy
|
from PyQt5.QtWidgets import QLabel, QSizePolicy
|
||||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt
|
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt
|
||||||
@ -85,6 +86,7 @@ class KeyHintView(QLabel):
|
|||||||
Args:
|
Args:
|
||||||
prefix: The current partial keystring.
|
prefix: The current partial keystring.
|
||||||
"""
|
"""
|
||||||
|
_, prefix = re.match(r'^(\d*)(.*)', prefix).groups()
|
||||||
if not prefix:
|
if not prefix:
|
||||||
self._show_timer.stop()
|
self._show_timer.stop()
|
||||||
self.hide()
|
self.hide()
|
||||||
|
@ -92,6 +92,18 @@ def test_suggestions(keyhint, config_stub):
|
|||||||
('a', 'yellow', 'c', 'message-info cmd-ac'))
|
('a', 'yellow', 'c', 'message-info cmd-ac'))
|
||||||
|
|
||||||
|
|
||||||
|
def test_suggestions_with_count(keyhint, config_stub):
|
||||||
|
"""Test that keyhints are shown based on a prefix."""
|
||||||
|
bindings = {'normal': {'aa': 'message-info cmd-aa'}}
|
||||||
|
config_stub.val.bindings.default = bindings
|
||||||
|
config_stub.val.bindings.commands = bindings
|
||||||
|
|
||||||
|
keyhint.update_keyhint('normal', '2a')
|
||||||
|
assert keyhint.text() == expected_text(
|
||||||
|
('a', 'yellow', 'a', 'message-info cmd-aa'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_special_bindings(keyhint, config_stub):
|
def test_special_bindings(keyhint, config_stub):
|
||||||
"""Ensure a prefix of '<' doesn't suggest special keys."""
|
"""Ensure a prefix of '<' doesn't suggest special keys."""
|
||||||
bindings = {'normal': {
|
bindings = {'normal': {
|
||||||
|
Loading…
Reference in New Issue
Block a user