talonvoice / talon

Issue Tracker for the main Talon app
85 stars 0 forks source link

overriding edit.line_insert_down in empty context does not work #657

Closed rntz closed 5 months ago

rntz commented 5 months ago

foo.py:

from talon import Context

ctx = Context()

@ctx.action_class("edit")
class EditActions:
    def line_insert_down():
        print(" ********** WAT ********** ")
        actions.edit.line_end()
        actions.key("enter")

Now with talonhub/community installed, say slap. This should run edit.line_insert_down. But it does not print WAT and does not run edit.line_end. Instead, on Mac OS, it presses cmd-right enter. This does not do the right thing in Emacs, for instance.

Note that talonhub/community has the above definition of line_insert_down in core/edit/edit.py, except for printing "WAT". I've just given it here as a minimal repro.

If you make the context more specific, eg ctx.matches = "app: Emacs", it works. This is my current workaround.

I haven't tried reproing with completely vanilla community; it's possible it's some weird interaction effect with the rest of my setup. Don't have time to try to minimize right now.

This appears to also affect edit.select_word - perhaps all edit actions, or all actions whatsoever, are affected?

talon 0.4.0-322-gf6ba MacOS Sonoma 14.4.1

rntz commented 5 months ago

Apparently this happens because talon grew default implementations while I wasn't looking, so the context in core/edit/edit.py needs to be more specific. IMO anything in the user directory would ideally override the default implementations, even if it's in an empty context.

Also IMO, this should probably be the default implementation of line_insert_down:

@ctx.action_class("edit")
class EditActions:
    def line_insert_down():
        actions.edit.line_end()
        actions.key("enter")
lunixbochs commented 5 months ago

should be fixed in next beta (also, fwiw that is the default implementation of line_insert_down on mac)