diff --git a/src/input_handler.cc b/src/input_handler.cc index b378b871..b7f424aa 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1242,8 +1242,7 @@ private: auto& selections = context().selections(); for (auto& sel : selections) { - auto cursor = context().has_window() ? context().window().offset_coord(sel.cursor(), offset) - : context().buffer().offset_coord(sel.cursor(), offset); + auto cursor = context().buffer().offset_coord(sel.cursor(), offset); sel.anchor() = sel.cursor() = cursor; } selections.sort_and_merge_overlapping(); diff --git a/src/normal.cc b/src/normal.cc index bd124ff6..d9f23f1b 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1696,9 +1696,7 @@ void move(Context& context, NormalParams params) auto& selections = context.selections(); for (auto& sel : selections) { - auto cursor = context.has_window() ? context.window().offset_coord(sel.cursor(), offset) - : context.buffer().offset_coord(sel.cursor(), offset); - + auto cursor = context.buffer().offset_coord(sel.cursor(), offset); sel.anchor() = mode == SelectMode::Extend ? sel.anchor() : cursor; sel.cursor() = cursor; } diff --git a/src/window.cc b/src/window.cc index 3ba1a8ee..52da799a 100644 --- a/src/window.cc +++ b/src/window.cc @@ -322,38 +322,13 @@ BufferCoord Window::buffer_coord(DisplayCoord coord) const return {0,0}; if (coord <= 0_line) coord = {0,0}; - if ((int)coord.line >= m_display_buffer.lines().size()) + if ((size_t)coord.line >= m_display_buffer.lines().size()) coord = DisplayCoord{(int)m_display_buffer.lines().size()-1, INT_MAX}; return find_buffer_coord(m_display_buffer.lines()[(int)coord.line], buffer(), coord.column); } -BufferCoord Window::offset_coord(BufferCoord coord, CharCount offset) -{ - return buffer().offset_coord(coord, offset); -} - -BufferCoordAndTarget Window::offset_coord(BufferCoordAndTarget coord, LineCount offset) -{ - auto line = clamp(coord.line + offset, 0_line, buffer().line_count()-1); - DisplayBuffer display_buffer; - DisplayBuffer::LineList& lines = display_buffer.lines(); - lines.emplace_back(AtomList{ {buffer(), coord.line, coord.line+1} }); - lines.emplace_back(AtomList{ {buffer(), line, line+1} }); - display_buffer.compute_range(); - - BufferRange range{ std::min(line, coord.line), std::max(line,coord.line)+1}; - - InputHandler input_handler{{ *m_buffer, Selection{} }, Context::Flags::Transient}; - input_handler.context().set_window(*this); - m_highlighters.highlight(input_handler.context(), HighlightFlags::MoveOnly, display_buffer, range); - m_builtin_highlighters.highlight(input_handler.context(), HighlightFlags::MoveOnly, display_buffer, range); - - ColumnCount column = coord.target == -1 ? find_display_column(lines[0], buffer(), coord) : coord.target; - return { find_buffer_coord(lines[1], buffer(), column), column }; -} - void Window::clear_display_buffer() { m_display_buffer = DisplayBuffer{}; diff --git a/src/window.hh b/src/window.hh index 4e40dd62..1a5b9cef 100644 --- a/src/window.hh +++ b/src/window.hh @@ -44,9 +44,6 @@ public: bool needs_redraw(const Context& context) const; void force_redraw() { m_last_setup = Setup{}; } - BufferCoord offset_coord(BufferCoord coord, CharCount offset); - BufferCoordAndTarget offset_coord(BufferCoordAndTarget coord, LineCount offset); - void set_client(Client* client) { m_client = client; } void clear_display_buffer();