Skip to content
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

Undoing phrase expansion fails, if triggered by a hotkey #164

Closed
luziferius opened this issue Jul 6, 2018 · 1 comment
Closed

Undoing phrase expansion fails, if triggered by a hotkey #164

luziferius opened this issue Jul 6, 2018 · 1 comment
Assignees
Labels

Comments

@luziferius
Copy link
Collaborator

luziferius commented Jul 6, 2018

Classification:

Crash

Reproducibility:

Always

Summary

The KeypressHandler-thread crashes if a phrase expansion is triggered by a hotkey, and then is undone using the backspace key.

Steps to Reproduce

  • Assign an abbreviation to trick the checking logic.
  • Assign a hotkey to a phrase
  • Press the hotkey to expand the phrase
  • Press backspace to undo the expansion operation

Expected Results

  • Pasted/typed phrase should disappear

Actual Results

2018-07-06 10:17:04,670 INFO - service - Undoing last abbreviation expansion
Exception in thread KeypressHandler-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/thomas/Projekte/autokey/lib/autokey/iomediator/_iomediator.py", line 114, in run
    target.handle_keypress(rawKey, modifiers, key, windowName, windowClass)
  File "/home/thomas/Projekte/autokey/lib/autokey/service.py", line 180, in handle_keypress
    if self.__updateStack(key):
  File "/home/thomas/Projekte/autokey/lib/autokey/service.py", line 277, in __updateStack
    self.phraseRunner.undo_expansion()
  File "/home/thomas/Projekte/autokey/lib/autokey/service.py", line 416, in undo_expansion
    replay = self.lastPhrase.get_trigger_chars(self.lastBuffer)
  File "/home/thomas/Projekte/autokey/lib/autokey/model.py", line 822, in get_trigger_chars
    stringBefore, typedAbbr, stringAfter = self._partition_input(buffer, abbr)
  File "/home/thomas/Projekte/autokey/lib/autokey/model.py", line 249, in _partition_input
    stringBefore, typedAbbr, stringAfter = currentString.rpartition(abbr)
TypeError: must be str, not NoneType

Version

AutoKey version 0.95.1

Notes

It seems that "lastBuffer" contains the trigger abbreviation that was removed during expansion. This does not exist when using a hotkey, thus is not initialized.
Possible solutions:

  • Initialize with an empty string (""), so that the logic does not break with TypeErrors
  • Specifically handle this situation and skip the code, which is not needed in this case.
@luziferius luziferius self-assigned this Jul 6, 2018
@luziferius luziferius added the bug label Jul 6, 2018
@luziferius
Copy link
Collaborator Author

Fixed in abf3345.
Phrase expansion can now always be un-done, even if triggered by a hotkey or menu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant