Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a command to open standard goto-anything menu if nothing is selected #3

Open
MatmaRex opened this issue Dec 3, 2013 · 0 comments

Comments

@MatmaRex
Copy link

MatmaRex commented Dec 3, 2013

Let's provide a command to open standard goto-anything menu if nothing is selected. This would make it possible to seamlessly replace the standard menu with the one provided by this package. (It should probably not be bound to any hotkey by default, just documented as existing.)

It can be trivially implemented using something like below, but such copy-pasting looks like an ugly solution, and my Python is too rusty for something prettier.

class GotoSelectionIfAnyCommand(sublime_plugin.WindowCommand):
    def run(self):
        for region in self.window.active_view().sel():
            if region.empty():
                lineContents = "";
            else:
                lineContents = self.window.active_view().substr(region)

        if len(lineContents) > 0:
            while (lineContents[0] in "# "):
                lineContents = lineContents[1:]

        self.window.run_command("show_overlay", {"overlay": "goto", "text": lineContents + "!", "show_files": "true"})
        self.window.run_command("left_delete")

(Note that this is using the hack I proposed in pull request #2.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant