diff options
author | 2019-09-20 18:24:27 -0400 | |
---|---|---|
committer | 2019-09-20 18:24:27 -0400 | |
commit | b4e33d2425ddcc6d0ec907006a00702670abba3b (patch) | |
tree | 61b21d267d9b8df607f73d99efa756ff7fa24036 /core/ui.lua | |
parent | 13ccc798ec16d3c5c38638d76b67f4bb7ff7693e (diff) |
Restore rectangular selection state when switching between buffers.
Diffstat (limited to 'core/ui.lua')
-rw-r--r-- | core/ui.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/core/ui.lua b/core/ui.lua index 28494877..c39a0d15 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -339,8 +339,10 @@ events_connect(events.BUFFER_BEFORE_SWITCH, function() local buffer = buffer -- Save view state. buffer._anchor, buffer._current_pos = buffer.anchor, buffer.current_pos - buffer._anchor_virtual_space = buffer.selection_n_anchor_virtual_space[0] - buffer._caret_virtual_space = buffer.selection_n_caret_virtual_space[0] + local n = buffer.main_selection + buffer._anchor_virtual_space = buffer.selection_n_anchor_virtual_space[n] + buffer._caret_virtual_space = buffer.selection_n_caret_virtual_space[n] + buffer._sel_rectangle = buffer.selection_mode == buffer.SEL_RECTANGLE buffer._top_line = buffer:doc_line_from_visible(buffer.first_visible_line) buffer._x_offset = buffer.x_offset -- Save fold state. @@ -359,8 +361,10 @@ events_connect(events.BUFFER_AFTER_SWITCH, function() for i = 1, #buffer._folds do buffer:toggle_fold(buffer._folds[i]) end -- Restore view state. buffer:set_sel(buffer._anchor, buffer._current_pos) - buffer.selection_n_anchor_virtual_space[0] = buffer._anchor_virtual_space - buffer.selection_n_caret_virtual_space[0] = buffer._caret_virtual_space + local n = buffer.main_selection + buffer.selection_n_anchor_virtual_space[n] = buffer._anchor_virtual_space + buffer.selection_n_caret_virtual_space[n] = buffer._caret_virtual_space + if buffer._sel_rectangle then buffer.selection_mode = buffer.SEL_RECTANGLE end buffer:choose_caret_x() buffer:line_scroll(0, buffer:visible_from_doc_line(buffer._top_line) - buffer.first_visible_line) |