Sublime Forum

Problems with "find_under_prev"

#1

I’ve been trying to do a key binding that uses “find_under_prev”. So far, this code doesn’t work for me (it does nothing):

class FindUnderExpandBackwardCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.run_command("find_under_prev")
        # copy, regions = copy_regions(self.view)
        # if len(copy) > 0:
        #     regions.clear()
        #     a, b = copy[0].a, copy[0].b
        #     regions.add(sublime.Region(a, b))
        #     self.view.run_command('find_under_prev')
        # regions.add_all(copy)

On the other hand, if I replace

        self.view.run_command("find_under_prev")

with, say,

        self.view.run_command("toggle_comment")

the keyboard shortcut works as expected: comment is toggled.

Is there some bug with “find_under_prev”? Can someone replicate/test this behavior?

Thanks!

PS: I’m on mac, build 3176

0 Likes

#2

have you tried self.view.window().run_command("find_under_prev")?

0 Likes

#3

Thank you yes that worked.

I’m a bit murky on view vs window. I guess it always makes sense to try both…

0 Likes

#4

also, if you have https://packagecontrol.io/packages/PackageDev installed, and you type window.run_command(', and ask ST to show completions, it will show you the possible commands and their type.
Although it seems to suggest that find_under_prev is a TextCommand, so I’ll submit a PR to fix that…

0 Likes