New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send broken keychains in passthrough modes to browser #3683
base: main
Are you sure you want to change the base?
Conversation
All the code movement makes it really difficult to review this (and introduces a high chance of conflicts) I'm afraid. Can you please open a separate PR for getting rid of Some early feedback:
|
8cff673
to
bf38272
Compare
This PR is now based on #3689. |
Hmm, looks like the move is still there... Can you please rebase on the latest master? |
bf38272
to
5afb066
Compare
qutebrowser/keyinput/modeparsers.py
Outdated
@@ -154,6 +155,8 @@ class PassthroughKeyParser(CommandKeyParser): | |||
|
|||
Attributes: | |||
_mode: The mode this keyparser is for. | |||
_orig_sequence: Cuerrent sequence with no key_mappings applied |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cuerrent -> Current
qutebrowser/keyinput/modeparsers.py
Outdated
@@ -154,6 +155,8 @@ class PassthroughKeyParser(CommandKeyParser): | |||
|
|||
Attributes: | |||
_mode: The mode this keyparser is for. | |||
_orig_sequence: Cuerrent sequence with no key_mappings applied | |||
_ignore_next_key: Whether to pass the next key through |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a period here and on the line above.
qutebrowser/keyinput/modeparsers.py
Outdated
|
||
def __repr__(self): | ||
return utils.get_repr(self, mode=self._mode) | ||
|
||
def handle(self, e, *, dry_run=False): | ||
"""Override to pass the chain through on NoMatch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a period.
qutebrowser/keyinput/modeparsers.py
Outdated
if window is None: | ||
return match | ||
|
||
self._ignore_next_key = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems rather brittle, as you're not guaranteed that the event you posted will be the next event which is received. I haven't tested it, but it likely also breaks if there's more than one key in the original sequence.
I'm okay with it when there's no other solution, but I'd like to check whether there's a better way. Can you try adding an attribute to the press_event
/ release_event
object and see whether it's still there (via getattr(e, 'ignore', False)
or so) when you get it back?
qutebrowser/keyinput/modeparsers.py
Outdated
A self.Match member. | ||
""" | ||
if keyutils.is_modifier_key(e.key()) or self._ignore_next_key: | ||
self._ignore_next_key = self._ignore_next_key and dry_run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this - why do you only want to set self._ignore_next_key
if dry_run
is set?
|
||
def __repr__(self): | ||
return utils.get_repr(self, mode=self._mode) | ||
|
||
def handle(self, e, *, dry_run=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to duplicate a lot of the logic in BaseKeyParser.match
, so I'm wondering whether there's a better way. Maybe KeySequence
should have an original
attribute where the original is stored when using with_mappings
instead? Not sure how much easier this would make the code without seeing it though - what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a patch that adds a without_mappings
method to KeySequence
, to see how the code looks would look like. It's kind of clunky and incomplete though (even has pylint errors), because KeySequence
is used pretty much as an immutable object.
If you want, I can rewrite the KeySequence
class to be more mutable, but that would probably belong in it's own PR.
https://gist.github.com/jakanaka-evan/4973c4a4e46e8e3bdae57b17dba0e26c
qutebrowser/keyinput/modeparsers.py
Outdated
|
||
def clear_keystring(self): | ||
"""Override to also clear the original sequence.""" | ||
if self._orig_sequence: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why bother with the check? You can just clear it unconditionally.
"""Override to also clear the original sequence.""" | ||
if self._orig_sequence: | ||
self._orig_sequence = keyutils.KeySequence() | ||
super().clear_keystring() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually additional things are done after the super()
call, not before it.
5afb066
to
ada54bb
Compare
ada54bb
to
29e06d3
Compare
I planned to take a look at this during my holidays before starting to learn for exams, but I didn't manage to do so (mainly because of a lot of issues with Qt 5.11...). I'll get back to it in September though! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have an opinion between the alternative patch and the current one, but something that does need to be fixed is not respecting input.partial_timeout
in passthrough mode. Since lifting it into commandkeyparser is probably not desirable, maybe there could be a helper function to set up the timeouts? A little bit of duplication is probably fine though :)
29e06d3
to
f2c3d27
Compare
The last two commits address the |
c37de35
to
7124f42
Compare
Fixes #1044.
This change is