Sublime Forum

Bug on show_overlay goto

#1

There is a bug on the goto panel when you try to open it with show_overlay command, it will not open correctly if you try to use the ‘#’ in the search.

Example. create a project that contains a file, named:
app/code/community/MagicToolbox/MagicZoomPlus/Model/Observer.php
with the following content:
<?php

class MagicToolbox_MagicZoomPlus_Model_Observer {
    public function fixLayoutUpdates($observer) {
    }
}

if you try to create a plugin with command like this:

class MyPluginCommand(sublime_plugin.TextCommand):
    def run(self, view):
            sublime_api.window_run_command(
                self.view.window().id(),
                'show_overlay',
                {
                    'overlay': 'goto',
                    'show_files': True,
                    'text': 'MagicToolbox/MagicZoomPlus/Model/Observer#fixLayoutUpdates'
                }
            )

it will not display the file on first hand. but if you remove all the text from the search input, and then paste it again’MagicToolbox/MagicZoomPlus/Model/Observer#fixLayoutUpdates it will display the file and highlight the function.

Not sure if there is another way to achieve the same, but this seems like an issue to me.

0 Likes

#2

I answered this on the SO post linked below (for cross reference purposes), but it would appear that the text argument that you can provide to show_overlay just sets the initial text in the overlay but doesn’t apply any special logic to it other than as a text filter (presumably because this command can open several different overlays).

In order to do this in a plugin you need to open the overlay and then add the text separately. The linked SO answer has an example of doing that in a plugin.

Out of curiosity, is there a reason you’re going right down to the bare API to invoke window.run_command() here? Also worth noting, the second argument to your TextCommand is named view, but it’s actually an edit object and not a view.

0 Likes

#3

yes I saw your answer on stackoverflow, thank you very much.

I am calling the bare API just because I dont know better. I havent find much documentation about writing sublime plugins other than the official webpage for sublime, which does not explain a lot.

Do you know some other sources from where I can learn?

How would you call the window.run_command() ?

0 Likes

#4

Official API reference.

Instead of:

sublime_api.window_run_command(
    self.view.window().id(),
    'show_overlay',
    args
)

Use:

self.view.window().run_command(
    'show_overlay',
    args
)
0 Likes

#5

Ok, the workaround for creating the plugins is working properly, when I do the insert right after the show_overlay.

Still, don’t you think this should still be reported as an issue on the API / Interface for plugin automation?

I mean, if you do exactly the same but instead of passing MagicToolbox/MagicZoomPlus/Model/Observer#fixLayoutUpdates you pass only the filename MagicToolbox/MagicZoomPlus/Model/Observer*, the filter work exactly the same as if you would have typed it yourself.

0 Likes

#6

There is not (yet) any official documentation on commands that I’m aware of that says what this is supposed to do, but observably it just applies some filter text as the initial text of the control. I think the difference between your two examples is that one filters the list of files and one applies special Goto logic to also fuzzy search the file that’s ultimately selected, so at some level it makes sense that it works one way and not the other.

It might be a bug but it also might be by design since it’s pretty easy to get it to do what you want if you’re making a plugin anyway and the Devs seem to favor providing the building blocks you need for functionality rather than trying to cater to everything.

As such you could log it if for no other reason to get official clarification on whether it’s doing what they think it should or not.

0 Likes