Sublime Forum

Can you fall back to default key command?

#1

First, some background:
The Sublime Git Package binds “Enter” to the GotoDiff command in the context of diff syntax.
This works well for “pure” diff files, but it throws in the context of a diff file that is the result of a manual hunk editing mode. In this context, it’s also useful to be able to use the default Enter action.
So I modified the plugin to use this code if it’s not a “real” diff file:

            for sel in self.view.sel():
                self.view.insert(edit, sel.begin(), "\n")

Now that work in the most basic case, but e.g. if you have a text selection, normally Enter would delete the selection, the above doesn’t.
So the question is, is there a way to fall back on the original command that was overwritten in the key binding? I simply want to say, oh, I didn’t want to execute this command after all, please do whatever the default was. Or if there’s not, maybe my code could be improved?

0 Likes

#2

I don’t think so. In this case you could either call view.replace instead, or view.run_command(‘insert’,{‘characters’:’\n’}), which is a different sort of insert as far as I can tell. If you run sublime.log_commands(True) in the console, you can see what happens when you press enter, which is how I came up with the view.insert thing.

0 Likes

#3

Thanks, the other command works well!

0 Likes