From 1e38045d702ec6eb2425016d9b02636270ab1b1e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 12 Aug 2023 13:40:55 +1000 Subject: Only make cursor visible after buffer or selection change Kakoune now does not touch cursors when scrolling. It checks if either the buffer or selections has been modified since last redraw. Fixes #4124 Fixes #2844 --- src/input_handler.cc | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/input_handler.cc') diff --git a/src/input_handler.cc b/src/input_handler.cc index 66d30391..ef45e149 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1870,25 +1870,27 @@ void scroll_window(Context& context, LineCount offset, bool mouse_dragging) win_pos.line = clamp(win_pos.line + offset, 0_line, line_count-1); - 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(); + 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(); - auto cursor_off = mouse_dragging ? win_pos.line - window.position().line : 0; + auto cursor_off = win_pos.line - window.position().line; - 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); - BufferCoord new_anchor = (mouse_dragging or new_cursor == cursor) ? anchor : new_cursor; + const ColumnCount tabstop = context.options()["tabstop"].get(); + auto new_cursor = buffer.offset_coord(cursor, line - cursor.line, tabstop); - window.set_position(win_pos); - main_selection = { new_anchor, new_cursor }; + main_selection = { anchor, new_cursor }; - selections.sort_and_merge_overlapping(); + selections.sort_and_merge_overlapping(); + } } } -- cgit v1.2.3