From 9c0c6b8fd5a7ea8b819798add9f0605da749062b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 23 Aug 2023 14:09:47 +1000 Subject: Revert "Only make cursor visible after buffer or selection change" This is currently broken on various corner cases and breaks the "master branch should be good for day to day work" implicit rule, ongoing work to stabilize this feature will take place on the no-cursor-move-on-scroll branch until its deemed ready. This reverts commit 1e38045d702ec6eb2425016d9b02636270ab1b1e. Closes #4963 --- src/input_handler.cc | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/input_handler.cc') diff --git a/src/input_handler.cc b/src/input_handler.cc index ef45e149..66d30391 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1870,27 +1870,25 @@ void scroll_window(Context& context, LineCount offset, bool mouse_dragging) win_pos.line = clamp(win_pos.line + offset, 0_line, line_count-1); - window.set_position(win_pos); - if (mouse_dragging) - { - ScopedSelectionEdition selection_edition{context}; - SelectionList& selections = context.selections(); - Selection& main_selection = selections.main(); - const BufferCoord anchor = main_selection.anchor(); - const BufferCoordAndTarget cursor = main_selection.cursor(); + ScopedSelectionEdition selection_edition{context}; + SelectionList& selections = context.selections(); + Selection& main_selection = selections.main(); + const BufferCoord anchor = main_selection.anchor(); + const BufferCoordAndTarget cursor = main_selection.cursor(); - auto cursor_off = win_pos.line - window.position().line; + auto cursor_off = mouse_dragging ? win_pos.line - window.position().line : 0; - auto line = clamp(cursor.line + cursor_off, win_pos.line + scrolloff.line, - win_pos.line + win_dim.line - 1 - scrolloff.line); + auto line = clamp(cursor.line + cursor_off, win_pos.line + scrolloff.line, + win_pos.line + win_dim.line - 1 - scrolloff.line); - const ColumnCount tabstop = context.options()["tabstop"].get(); - auto new_cursor = buffer.offset_coord(cursor, line - cursor.line, tabstop); + const ColumnCount tabstop = context.options()["tabstop"].get(); + auto new_cursor = buffer.offset_coord(cursor, line - cursor.line, tabstop); + BufferCoord new_anchor = (mouse_dragging or new_cursor == cursor) ? anchor : new_cursor; - main_selection = { anchor, new_cursor }; + window.set_position(win_pos); + main_selection = { new_anchor, new_cursor }; - selections.sort_and_merge_overlapping(); - } + selections.sort_and_merge_overlapping(); } } -- cgit v1.2.3