diff options
author | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2021-06-08 21:37:53 -0400 |
---|---|---|
committer | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2021-06-08 21:37:53 -0400 |
commit | fe7135350f64ba10a63626c6f363cc48a0679438 (patch) | |
tree | c3020a0a0b944c3641ff7b3a7e1b35bc93dc779e | |
parent | 1ecb56e1ddb574a3ca8005d3fc97c0792625b0db (diff) |
Do not attempt to restore the selection when typing after selecting/deleting all text.
This extends r3135 to also handle auto-paired characters.
-rw-r--r-- | core/ui.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/ui.lua b/core/ui.lua index 21fcbf80..b006c84a 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -375,8 +375,10 @@ local function restore_buffer_state() view.x_offset = buffer._x_offset or 0 end events.connect(events.BUFFER_AFTER_SWITCH, restore_buffer_state) -events.connect(events.BUFFER_AFTER_REPLACE_TEXT, - function() if buffer.length > 1 then restore_buffer_state() end end) +events.connect(events.BUFFER_AFTER_REPLACE_TEXT, function() + local anchor, pos = buffer._anchor or 0, buffer._current_pos or 0 + if anchor <= buffer.length and pos <= buffer.length then restore_buffer_state() end +end) -- Updates titlebar and statusbar. local function update_bars() |