diff --git a/src/main.cc b/src/main.cc index 04a845a9..a2b4aeb8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -323,7 +323,7 @@ void do_go(Window& window, int count) BufferIterator target = window.buffer().iterator_at(BufferCoord(count, 0)); - window.move_cursor_to(window.line_and_column_at(target)); + window.move_cursor_to(target); } else { @@ -335,7 +335,7 @@ void do_go(Window& window, int count) { BufferIterator target = window.buffer().iterator_at(BufferCoord(0,0)); - window.move_cursor_to(window.line_and_column_at(target)); + window.move_cursor_to(target); break; } case 'l': @@ -350,7 +350,7 @@ void do_go(Window& window, int count) { BufferIterator target = window.buffer().iterator_at( BufferCoord(window.buffer().line_count() - 1, 0)); - window.move_cursor_to(window.line_and_column_at(target)); + window.move_cursor_to(target); break; } } diff --git a/src/window.cc b/src/window.cc index 92b8ef5c..3cd7dc33 100644 --- a/src/window.cc +++ b/src/window.cc @@ -261,7 +261,7 @@ BufferString Window::selection_content() const void Window::move_cursor(const WindowCoord& offset, bool append) { if (not append) - move_cursor_to(cursor_position() + offset); + move_cursor_to(iterator_at(cursor_position() + offset)); else { for (auto& sel : m_selections) @@ -273,11 +273,10 @@ void Window::move_cursor(const WindowCoord& offset, bool append) } } -void Window::move_cursor_to(const WindowCoord& new_pos) +void Window::move_cursor_to(const BufferIterator& iterator) { - BufferIterator target = iterator_at(new_pos); m_selections.clear(); - m_selections.push_back(Selection(target, target)); + m_selections.push_back(Selection(iterator, iterator)); scroll_to_keep_cursor_visible_ifn(); } diff --git a/src/window.hh b/src/window.hh index da1b694c..98e208a8 100644 --- a/src/window.hh +++ b/src/window.hh @@ -61,7 +61,7 @@ public: WindowCoord line_and_column_at(const BufferIterator& iterator) const; void move_cursor(const WindowCoord& offset, bool append = false); - void move_cursor_to(const WindowCoord& new_pos); + void move_cursor_to(const BufferIterator& iterator); void clear_selections(); void select(const Selector& selector, bool append = false);