Merge remote-tracking branch 'origin/pr/3789'
This commit is contained in:
commit
8531f89ca3
@ -172,6 +172,7 @@ class HintContext:
|
||||
tab = attr.ib(None)
|
||||
group = attr.ib(None)
|
||||
hint_mode = attr.ib(None)
|
||||
first = attr.ib(False)
|
||||
|
||||
def get_args(self, urlstr):
|
||||
"""Get the arguments, with {hint-url} replaced by the given URL."""
|
||||
@ -612,6 +613,9 @@ class HintManager(QObject):
|
||||
modeman.enter(self._win_id, usertypes.KeyMode.hint,
|
||||
'HintManager.start')
|
||||
|
||||
if self._context.first:
|
||||
self._fire(strings[0])
|
||||
return
|
||||
# to make auto_follow == 'always' work
|
||||
self._handle_auto_follow()
|
||||
|
||||
@ -620,7 +624,8 @@ class HintManager(QObject):
|
||||
@cmdutils.argument('win_id', win_id=True)
|
||||
def start(self, # pylint: disable=keyword-arg-before-vararg
|
||||
group=webelem.Group.all, target=Target.normal,
|
||||
*args, win_id, mode=None, add_history=False, rapid=False):
|
||||
*args, win_id, mode=None, add_history=False, rapid=False,
|
||||
first=False):
|
||||
"""Start hinting.
|
||||
|
||||
Args:
|
||||
@ -632,6 +637,7 @@ class HintManager(QObject):
|
||||
add_history: Whether to add the spawned or yanked link to the
|
||||
browsing history.
|
||||
group: The element types to hint.
|
||||
first: Click the first hinted element without prompting.
|
||||
|
||||
- `all`: All clickable elements.
|
||||
- `links`: Only links.
|
||||
@ -713,6 +719,7 @@ class HintManager(QObject):
|
||||
self._context.rapid = rapid
|
||||
self._context.hint_mode = mode
|
||||
self._context.add_history = add_history
|
||||
self._context.first = first
|
||||
try:
|
||||
self._context.baseurl = tabbed_browser.current_url()
|
||||
except qtutils.QtValueError:
|
||||
|
@ -2271,6 +2271,7 @@ bindings.default:
|
||||
;R: hint --rapid links window
|
||||
;d: hint links download
|
||||
;t: hint inputs
|
||||
gi: hint inputs --first
|
||||
h: scroll left
|
||||
j: scroll down
|
||||
k: scroll up
|
||||
|
@ -509,3 +509,17 @@ Feature: Using hints
|
||||
And I press the key "hello"
|
||||
And I press the key "<Enter>"
|
||||
Then data/hello.txt should be loaded
|
||||
|
||||
Scenario: Using --first with normal links
|
||||
When I open data/hints/html/simple.html
|
||||
And I hint with args "all --first"
|
||||
Then data/hello.txt should be loaded
|
||||
|
||||
Scenario: Using --first with inputs
|
||||
When I open data/hints/input.html
|
||||
And I hint with args "inputs --first"
|
||||
And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log
|
||||
# ensure we clicked the first element
|
||||
And I run :jseval console.log(document.activeElement.id == "qute-input");
|
||||
And I run :leave-mode
|
||||
Then the javascript message "true" should be logged
|
||||
|
Loading…
Reference in New Issue
Block a user