Sublime Forum

Debugging custom plugin loading

#1

Hi everyone,

I feel like this is some kind of basic mistake but for the life of me I can’t seem to get to the bottom of it. My custom plugins are not loading after previous working.

On Mac in my “Application Support/Sublime Text/Packages” directory I have a folder called lets say “Project” and inside that I have plugins like project_some_action.py. The plugin files themselves look like this:

import sublime
import sublime_plugin

class ProjectSomeActionCommand(sublime_plugin.TextCommand):
   def run(self, edit):
      print("This is a debug message")

And my key handlers look like:

[
    { "keys": ["super+shift+k"], "command": "project_some_action" },`
    ...

But when I use the key command, it gives me this error:

no command for selector: noop:

And if I try to run the commands manually, there’s no console output

view.run_command('test')

It used to work, but maybe there was a software update or something and now it isn’t.

Thanks

0 Likes

#2

Maybe there is another keybinding using the same key in ...? Or in your Preferences --> Keybindings.

0 Likes

#3

This command is not the same as the one you bound to the key, which is probably not what you actually tried, but just in case.

But as @jfcherng pointed out, there may be another key that is taking precedence. You can tell for sure by entering sublime.log_commands() in the console to see what command the binding is trying to trigger.

0 Likes

#4

Hi there, thanks @jfcherng and @OdatNurd for your suggestions.

I enabled logging and I see a given plugin getting logged, but it doesn’t seem to be running the associated code.

As a specific example, I have “/Users/me/Library/Application Support/Sublime Text/Packages/User/Default (OSX).sublime-keymap” which contains my custom key bindings.

It begins:

    [
        { "keys": ["super+shift+k"], "command": "project_extract_keys" },

With logging, that keystroke produces the console output:

    command: project_extract_keys
    command: project_extract_keys
    no command for selector: noop:

But even if the file contains logging code, nothing else from the plugin code seems to be running:

import sublime, sublime_plugin
import re

    class ProjectExtractKeysCommand(sublime_plugin.TextCommand):

      def run(self, edit):
        print(123)

When I try to run manually, it gives me weird console output:

>>> view.run_command('project_extract_keys')
view.run_command('test')

Any suggestions for further debugging? This is a tree of my application support directory more generally for extra context:

/Users/me/Library/Application Support/Sublime Text
├── Installed Packages
│   ├── Automatic Backups.sublime-package
│   ├── Github Color Theme.sublime-package
│   ├── LogView.sublime-package
│   ├── Package Control.sublime-package
│   ├── PackageResourceViewer.sublime-package
│   ├── Unicode Character Insert.sublime-package
│   └── WordingStatus.sublime-package
├── Lib
│   ├── python33
│   │   └── package_control.py
│   └── python38
│       └── package_control.py
├── Local
│   ├── Auto Save Session.sublime_session
│   ├── Backup Auto Save Session.sublime_session
│   ├── Backup Session.sublime_session
│   ├── License.sublime_license
│   └── Session.sublime_session
├── Log
├── Packages
│   ├── Project
│   │   ├── Default (OSX).sublime-keymap // custom key bindings
│   │   ├── README.md
│   │   ├── project_extract_keys.py
│   │   ├── ~20 files like project_action.py similar to previous
│   │   ├── date_insert.py
│   │   ├── smart_quotes.py
│   │   └── test_command.py
│   ├── Default
│   │   ├── Default (OSX).sublime-keymap
│   │   └── Default.sublime-commands
│   └── User
│       ├── Distraction Free.sublime-settings
│       ├── Package Control.sublime-settings
│       ├── Package Control.user-ca-bundle
│       ├── Preferences.sublime-settings
│       ├── R Console.sublime-settings
│       └── nc.sublime-snippet
0 Likes

#5

Off the top of my head:

  1. Does some other plugin somewhere else also implement the same command? Packages load in a specific order, and if more than one defines the same command as something else, the last one “wins”.

  2. The same can also be said for sublime-keymap files; they load in a particular order so other things can override your keys. The User package is loaded last for this reason, but even then, the bindings in the file apply from the bottom of the file up, so if the same binding appears more than once, the lower one “wins”. This doesn’t seem to be your issue directly though, if the command logger is appropriately showing its trying to run your command.

  3. What version of Sublime are you running? In newer versions, the User package always runs in the 3.8 plugin host, while other packages are 3.3 by default unless they contain a .python-version file. I don’t know exactly what might happen if the same command is defined by multiple plugins running in different hosts, but it’s probably not what you expect.

  4. If that command is printing that output (i.e. you run your command and it sends that run_command text to the console, then apart from the above, I would use Tools > Developer > Profile Plugins. In the output, look for any plugins that are defining on_text_command or on_window_command; those events can intercept commands and rewrite the request to run something different instead

You may want to also use sublime.log_input() along withsublime.log_commands() just to verify that the input that you’re providing is as you expect (and check and see if a second input is maybe logged between the log of your command and the log of the noop one.

0 Likes

#6

Can you try to reinstall Sublime Text? I suspect that something builtin has been modified.


Also these don’t look like how people do it, usually. But they probably are not related to your issue.


│   ├── Default
│   │   ├── Default (OSX).sublime-keymap
│   │   └── Default.sublime-commands
0 Likes

#7

@jfcherng Full reinstall + deleted Application support folder resolved the issue. I guess some combination of things was corrupt but not sure what. Thanks also @OdatNurd!

1 Like