diff options
author | Teddy Wing | 2018-08-28 08:42:36 +0200 |
---|---|---|
committer | Teddy Wing | 2018-08-28 08:42:36 +0200 |
commit | 2a3731003a53104340658c95491dc9587d2cea6c (patch) | |
tree | ffa4c8d5c5e91e79245f03f9440bcc4982e6368b | |
parent | 815bf3e8601b6d0cfb0296c6f2c302aaf5059b23 (diff) | |
download | DomeKey-2a3731003a53104340658c95491dc9587d2cea6c.tar.bz2 |
HeadphoneKey(runAction): Take `strlen` out of loop
This appears to fix the weirdness I was having in
815bf3e8601b6d0cfb0296c6f2c302aaf5059b23, where extra characters were
getting sent to `simpleKeyPressWithKey:` even though there was only 1
element (the correct number of elements) in the `action` array/string.
I guess before the length was getting recalculated on each iteration of
the loop.
Previously, this would result in the Vim `x` command getting entered
just after the map action (for example `j`).
Now it appears to work correctly.
-rw-r--r-- | DomeKey/HeadphoneKey.m | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m index e955128..1d5811b 100644 --- a/DomeKey/HeadphoneKey.m +++ b/DomeKey/HeadphoneKey.m @@ -77,7 +77,8 @@ const CKeyActionResult *result = c_run_key_action(trigger, count); if (*result->kind == MapKind_Map) { - for (int i = 0; i < strlen(result->action); i++) { + size_t length = strlen(result->action); + for (size_t i = 0; i < length; i++) { [KeyboardSimulator simpleKeyPressWithKey:result->action[i]]; } } |