diff options
| author | Maxime Coste <mawww@kakoune.org> | 2023-08-12 13:40:55 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2023-08-16 21:02:42 +1000 |
| commit | 1e38045d702ec6eb2425016d9b02636270ab1b1e (patch) | |
| tree | 0298a655119e5d87d9650d5aadc0f1fc76ffcbfd /src/input_handler.cc | |
| parent | 6942a4c0c9428a9e2ddb65de3969d2dcb5c5eb2f (diff) | |
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
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 30 |
1 files changed, 16 insertions, 14 deletions
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<int>(); - 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<int>(); + 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(); + } } } |
