def run(self, edit, extend=False, character=None, mode=None, count=1): def f(view, s): line_text = view.substr(sublime.Region(view.line(s.b).a, s.b)) a, b = view.line(s.b).a, s.b final_offset = -1 try: for i in range(count): line_text = view.substr(sublime.Region(a, b)) match_in_line = line_text.rindex(character) final_offset = match_in_line b = view.line(s.a).a + final_offset except ValueError: pass if final_offset > -1: pt = view.line(s.b).a + final_offset state = VintageState(view) if state.mode == MODE_VISUAL or mode == _MODE_INTERNAL_NORMAL: return sublime.Region(s.a, pt + 1) return sublime.Region(pt + 1, pt + 1) return s if character is None: return else: state = VintageState(self.view) state.last_character_search = character regions_transformer(self.view, f)
def run(self, edit, extend=False, character=None, mode=None, count=1): def f(view, s): line_text = view.substr(sublime.Region(view.line(s.b).a, s.b)) a, b = view.line(s.b).a, s.b final_offset = -1 try: for i in range(count): line_text = view.substr(sublime.Region(a, b)) match_in_line = line_text.rindex(character) final_offset = match_in_line b = view.line(s.a).a + final_offset except ValueError: pass if final_offset > -1: pt = view.line(s.b).a + final_offset state = VintageState(view) if state.mode == MODE_VISUAL or mode == _MODE_INTERNAL_NORMAL: return sublime.Region(s.a, pt + 1) return sublime.Region(pt + 1, pt + 1) return s if character is None: return else: state = VintageState(self.view) state.last_character_search = character regions_transformer(self.view, f)
def run(self, edit, extend=False, character=None, mode=None, count=1): def f(view, s): eol = view.line(s.b).end() if not s.empty(): eol = view.line(s.b - 1).end() match = s offset = 1 if count > 1 else 0 for i in range(count): # Define search range as 'rest of the line to the right'. if state.mode != MODE_VISUAL: search_range = sublime.Region(min(match.b + 1 + offset, eol), eol) else: search_range = sublime.Region(min(match.b + offset, eol), eol) match = find_in_range(view, character, search_range.a, search_range.b, sublime.LITERAL) # Count too high or simply no match; break. if match is None: match = s break if state.mode == MODE_VISUAL or mode == _MODE_INTERNAL_NORMAL: if match == s: # FIXME: It won't blink because the current light can't be highlighted right # now (we are in command mode and there is a selection on the screen. Perhaps # we can make the gutter blink instead.) utils.blink() return s return sublime.Region(s.a, match.b - 1) if match == s: utils.blink() return s return sublime.Region(match.a - 1, match.a - 1) # TODO: Give feedback to the user that the search failed? if character is None: return else: state = VintageState(self.view) state.last_character_search = character regions_transformer(self.view, f)
def run(self, edit, extend=False, character=None, mode=None, count=1): def f(view, s): eol = view.line(s.b).end() if not s.empty(): eol = view.line(s.b - 1).end() match = s offset = 1 if count > 1 else 0 for i in range(count): # Define search range as 'rest of the line to the right'. if state.mode != MODE_VISUAL: search_range = sublime.Region( min(match.b + 1 + offset, eol), eol) else: search_range = sublime.Region(min(match.b + offset, eol), eol) match = find_in_range(view, character, search_range.a, search_range.b, sublime.LITERAL) # Count too high or simply no match; break. if match is None: match = s break if state.mode == MODE_VISUAL or mode == _MODE_INTERNAL_NORMAL: if match == s: # FIXME: It won't blink because the current light can't be highlighted right # now (we are in command mode and there is a selection on the screen. Perhaps # we can make the gutter blink instead.) utils.blink() return s return sublime.Region(s.a, match.b - 1) if match == s: utils.blink() return s return sublime.Region(match.a - 1, match.a - 1) # TODO: Give feedback to the user that the search failed? if character is None: return else: state = VintageState(self.view) state.last_character_search = character regions_transformer(self.view, f)
def run(self, edit, extend=False, character=None, mode=None, count=1): def f(view, s): offset = s.b + 1 - view.line(s.b).a a, eol = s.b + 1, view.line(s.b).b final_offset = -1 try: for i in range(count): line_text = view.substr(sublime.Region(a, eol)) match_in_line = line_text.index(character) final_offset = offset + match_in_line a = view.line(s.a).a + final_offset + 1 offset += match_in_line + 1 except ValueError: pass if final_offset > -1: pt = view.line(s.b).a + final_offset state = VintageState(view) if state.mode == MODE_VISUAL or mode == _MODE_INTERNAL_NORMAL: return sublime.Region(s.a, pt + 1) return sublime.Region(pt, pt) return s # TODO: Give feedback to the user that the search failed? if character is None: return else: state = VintageState(self.view) state.last_character_search = character regions_transformer(self.view, f)