diff --git a/src/editor.hh b/src/editor.hh index 402f2c9c..d99cb2ff 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -61,9 +61,8 @@ public: void flip_selections(); void keep_selection(int index); void remove_selection(int index); - void select(const BufferIterator& it, - SelectMode mode = SelectMode::Replace) - { select(Selection{ it, it }, mode); } + void select(const BufferCoord& c, SelectMode mode = SelectMode::Replace) + { auto it = m_buffer->iterator_at(c); select(Selection{ it, it }, mode); } void select(const Selection& sel, SelectMode mode = SelectMode::Replace); void select(const Selector& selector, diff --git a/src/normal.cc b/src/normal.cc index a3e24f50..3286d3c3 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -49,11 +49,8 @@ void goto_commands(Context& context) int count = context.numeric_param(); if (count != 0) { - BufferIterator target = - context.editor().buffer().iterator_at_line_begin(count-1); - context.push_jump(); - context.editor().select(target); + context.editor().select(BufferCoord{count - 1, 0}); if (context.has_window()) context.window().center_selection(); } diff --git a/src/window.cc b/src/window.cc index 73158972..6dea573e 100644 --- a/src/window.cc +++ b/src/window.cc @@ -176,20 +176,21 @@ void Window::scroll_to_keep_cursor_visible_ifn() } } -DisplayCoord Window::display_position(const BufferIterator& iterator) +DisplayCoord Window::display_position(const BufferCoord& coord) { DisplayCoord res{0,0}; for (auto& line : m_display_buffer.lines()) { - if (line.buffer_line() == iterator.line()) + if (line.buffer_line() == coord.line) { for (auto& atom : line) { auto& content = atom.content; if (content.has_buffer_range() and - iterator.coord() >= content.begin() and iterator.coord() < content.end()) + coord >= content.begin() and coord < content.end()) { - res.column += utf8::distance(buffer().iterator_at(content.begin()), iterator); + res.column += utf8::distance(buffer().iterator_at(content.begin()), + buffer().iterator_at(coord)); return res; } res.column += content.length(); diff --git a/src/window.hh b/src/window.hh index 8f842f06..25890e81 100644 --- a/src/window.hh +++ b/src/window.hh @@ -37,7 +37,7 @@ public: void scroll(LineCount offset); void update_display_buffer(); - DisplayCoord display_position(const BufferIterator& it); + DisplayCoord display_position(const BufferCoord& coord); HighlighterGroup& highlighters() { return m_highlighters; }