Supporting Quick Definition From a FileEditorProvider

I have built the Live Coding in Python plugin to visualize what happens as you run your Python code. It vertically splits the editor in half, and displays variable values and loop iterations in the right half, aligned with the Python code in the left half. That all works well, but I just noticed that the Quick Definition feature is broken.

Without my plugin installed, typing Ctrl+Shift+I on a Python function call will open up a small, modal window with just the function definition in it. With my plugin installed, it opens up a modal window with the function's whole file in it. If the function definition isn't near the top, you won't even see it.

I have diagnosed the problem, but I can't find a solution I like. First, the Quick Definition feature has a special case for the TextEditorProvider. Because my provider is not a subclass of TextEditorProvider, it just receives the whole file, not the definition in foundElement. I tried converting my provider to be a subclass, and that fixed the Quick Definition. However, then I couldn't use the HIDE_DEFAULT_EDITOR policy, because my editor would also get hidden! Without that policy, I see two options at the bottom of the editor: my live coding editor, and the default editor. My live coding editor is just a wrapper around the default, so I don't think it makes sense to show both, and it wastes a lot of real estate.

I would like to do one of two things:

  1. Find a better way to display the visualization on the right hand side, synchronized with the Python code on the left. If I didn't have to replace the TextEditorProvider, then the quick definition would probably continue to work.
  2. Make the quick definition work with my provider. Do I have to reimplement all of the code to find the definition? Does my provider even have enough information to know which definition to display? Does the API provide any hooks that I can use?

Please sign in to leave a comment.