def move(self): view = self.view doc = view.document y, x = view.cursor_pos if y == doc.num_lines - 1: return y += 1 line = doc.get_line(y) if tab_len(line, doc.tab_size) > view.last_x_pos: x = tab_pos_to_char_pos(line, view.last_x_pos, doc.tab_size) else: x = len(line) view.cursor_pos = (y, x)
def move(self): view = self.view doc = view.document y, x = self.newpos # we're explicitely setting x, so update last_x_pos view.last_x_pos = x # try and set where we clicked, otherwise set x to the end of the line line = doc.get_line(y) if tab_len(line, doc.tab_size) > view.last_x_pos: x = tab_pos_to_char_pos(line, view.last_x_pos, doc.tab_size) else: x = len(line) view.cursor_pos = (y, x)
def test_tab_pos_to_char_pos_alternative(): assert tab_pos_to_char_pos('a\t', 4, 8) == 1
def test_tab_pos_to_char_pos(): assert tab_pos_to_char_pos('\ta', 4, 8) == 0