VolumeScroll: fix broken start() and modernize modifier matching#367
Open
TowyTowy wants to merge 1 commit into
Open
VolumeScroll: fix broken start() and modernize modifier matching#367TowyTowy wants to merge 1 commit into
TowyTowy wants to merge 1 commit into
Conversation
The spoon errored on start and its event tap callback threw
"attempt to call a nil value (method 'sameMods')" because the tap
callback resolved helper methods through a self that was easily wrong,
and the hand-rolled sameMods/tableLength comparison relied on a
synthetic scroll event created in :init() just to capture flags.
- Match modifiers with event:getFlags():containExactly(self.mods),
removing sameMods(), tableLength() and the synthetic event in :init()
- Make :start() work with no arguments (defaults to { "cmd" })
and document the optional mods parameter in the signature
- Guard against devices with no output volume and clamp to 0..100
- Make :stop() safe to call before :start()
- Return self from init/start/stop per SPOONS.md chaining convention
Fixes Hammerspoon#341
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #341
VolumeScroll errored on
start()and its event tap callback threwattempt to call a nil value (method 'sameMods'). The tap callback resolved helper methods through aselfthat was easily wrong (the documented signature did not show themodsparameter, so dot-calls were common — which also let the tap object be garbage-collected, explaining the "tap eventually stops receiving events" symptom), and the hand-rolledsameMods/tableLengthcomparison relied on a synthetic scroll event created in:init()just to capture flags.event:getFlags():containExactly(self.mods), removingsameMods(),tableLength()and the synthetic event in:init():start()work with no arguments (defaults to{ "cmd" }) and document the optionalmodsparameter in the signature, with a colon-call note and usage example:stop()safe to call before:start()selffrominit/start/stopper SPOONS.md chaining conventionValidated with
luac -p, the CI docstring linter (build_docs.py -l), and a mocked-hslogic trace covering both error reproes from the issue.