diff options
author | 2019-09-19 14:19:52 -0400 | |
---|---|---|
committer | 2019-09-19 14:19:52 -0400 | |
commit | 13ccc798ec16d3c5c38638d76b67f4bb7ff7693e (patch) | |
tree | d94f4cb8c01d2b026eb11e2a768ae60a1fa16a8e /core/ui.lua | |
parent | e80ec842005ddeaece5c04f1cea8bccdb24c845a (diff) |
Restore virtual space state when switching between buffers.
Diffstat (limited to 'core/ui.lua')
-rw-r--r-- | core/ui.lua | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/core/ui.lua b/core/ui.lua index 295a24c3..28494877 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -339,6 +339,8 @@ 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] buffer._top_line = buffer:doc_line_from_visible(buffer.first_visible_line) buffer._x_offset = buffer.x_offset -- Save fold state. @@ -357,6 +359,8 @@ 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 buffer:choose_caret_x() buffer:line_scroll(0, buffer:visible_from_doc_line(buffer._top_line) - buffer.first_visible_line) |