Exemplo n.º 1
0
    def testSearchInRange(self):
        values = (
            (search_in_range(g_test_view, 'THIRTY', 1300, 1800), True),
            (search_in_range(g_test_view, 'THIRTY', 100, 100), None),
            (search_in_range(g_test_view, 'THIRTY', 100, 1000), None),
        )

        for actual, expected in values:
            self.assertEquals(actual, expected)
    def testSearchInRange(self):
        values = (
            (search_in_range(g_test_view, 'THIRTY', 1300, 1800), True),
            (search_in_range(g_test_view, 'THIRTY', 100, 100), None),
            (search_in_range(g_test_view, 'THIRTY', 100, 1000), None),
        )

        for actual, expected in values:
            self.assertEquals(actual, expected)
Exemplo n.º 3
0
    def search(self):
        if not getattr(self, "cmd", None):
            return
        SearchImpl.last_term = self.cmd
        sel = self.view.sel()[0]

        next_match = None
        if self.reversed:
            current_line = self.view.line(self.view.sel()[0])
            left_side = sublime.Region(current_line.begin(), self.view.sel()[0].begin())
            if ex_location.search_in_range(self.view, self.cmd, left_side.begin(), left_side.end()):
                next_match = ex_location.find_last_match(self.view, self.cmd, left_side.begin(), left_side.end())
            else:
                line_nr = ex_location.reverse_search(self.view, self.cmd,
                                                end=current_line.begin() - 1)
                if line_nr:
                    pt = self.view.text_point(line_nr - 1, 0)
                    next_match = self.view.find(self.cmd, pt)
        else:
            next_match = self.view.find(self.cmd, sel.end())
        if next_match:
            self.view.sel().clear()
            self.view.sel().add(next_match)
            self.view.show(next_match)
        else:
            sublime.status_message("VintageEx: Could not find:" + self.cmd)
Exemplo n.º 4
0
    def search(self):
        if not getattr(self, "cmd", None):
            return
        if self.remember:
            SearchImpl.last_term = self.cmd
        sel = self.start_sel[0]

        next_match = None
        if self.reversed:
            current_line = self.view.line(self.view.sel()[0])
            left_side = sublime.Region(current_line.begin(),
                                       self.view.sel()[0].begin())
            if ex_location.search_in_range(self.view, self.cmd,
                                           left_side.begin(),
                                           left_side.end(),
                                           self.flags):
                next_match = ex_location.find_last_match(self.view,
                                                         self.cmd,
                                                         left_side.begin(),
                                                         left_side.end(),
                                                         self.flags)
            else:
                line_nr = ex_location.reverse_search(self.view, self.cmd,
                                                end=current_line.begin() - 1,
                                                flags=self.flags)
                if line_nr:
                    pt = self.view.text_point(line_nr - 1, 0)
                    line = self.view.full_line(pt)
                    next_match = ex_location.find_last_match(self.view,
                                                             self.cmd,
                                                             line.begin(),
                                                             line.end(),
                                                             self.flags)
        else:
            next_match = self.view.find(self.cmd, sel.end(), self.flags)
        if next_match:
            self.view.sel().clear()
            if not self.remember:
                self.view.add_regions("vi_search", [next_match], "search.vi",
                                      sublime.DRAW_OUTLINED)
            else:
                self.view.sel().add(next_match)
            self.view.show(next_match)
        else:
            sublime.status_message("VintageEx: Pattern not found:" + self.cmd)
Exemplo n.º 5
0
    def search(self):
        if not getattr(self, "cmd", None):
            return
        if self.remember:
            SearchImpl.last_term = self.cmd
        sel = self.start_sel[0]

        next_match = None
        if self.reversed:
            current_line = self.view.line(self.view.sel()[0])
            left_side = sublime.Region(current_line.begin(),
                                       self.view.sel()[0].begin())
            if ex_location.search_in_range(self.view, self.cmd,
                                           left_side.begin(), left_side.end(),
                                           self.flags):
                next_match = ex_location.find_last_match(
                    self.view, self.cmd, left_side.begin(), left_side.end(),
                    self.flags)
            else:
                line_nr = ex_location.reverse_search(self.view,
                                                     self.cmd,
                                                     end=current_line.begin() -
                                                     1,
                                                     flags=self.flags)
                if line_nr:
                    pt = self.view.text_point(line_nr - 1, 0)
                    line = self.view.full_line(pt)
                    next_match = ex_location.find_last_match(
                        self.view, self.cmd, line.begin(), line.end(),
                        self.flags)
        else:
            next_match = self.view.find(self.cmd, sel.end(), self.flags)
        if next_match:
            self.view.sel().clear()
            if not self.remember:
                self.view.add_regions("vi_search", [next_match], "search.vi",
                                      sublime.DRAW_OUTLINED)
            else:
                self.view.sel().add(next_match)
            self.view.show(next_match)
        else:
            sublime.status_message("VintageEx: Pattern not found:" + self.cmd)