diff options
author | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2021-06-12 11:26:54 -0400 |
---|---|---|
committer | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2021-06-12 11:26:54 -0400 |
commit | 3ce1997b68b0454840870e35d84a4bb5feddfab3 (patch) | |
tree | f849a2d0ef73ed8666c1d61d5ab4a7137e80b473 | |
parent | c48b2e6ff5fdad2e7815972fb4d5d07d5de295af (diff) |
Fixed incorrect bitwise operation.
This consolidates changes from r3135 and r3149 and fixes an additional restore selection case.
-rw-r--r-- | core/events.lua | 2 | ||||
-rw-r--r-- | core/ui.lua | 5 | ||||
-rw-r--r-- | test/test.lua | 5 |
3 files changed, 5 insertions, 7 deletions
diff --git a/core/events.lua b/core/events.lua index 52b1dc37..f0c20fe3 100644 --- a/core/events.lua +++ b/core/events.lua @@ -415,7 +415,7 @@ end -- Emits events prior to and after replacing buffer text. M.connect(M.MODIFIED, function(position, mod, text, length) if mod & (DELETE | INSERT) == 0 or length ~= buffer.length then return end - if mod & (INSERT | UNDOREDO) > 0 then + if mod & (INSERT | UNDOREDO) == INSERT | UNDOREDO then -- Cannot emit BUFFER_AFTER_REPLACE_TEXT here because Scintilla will do things like update -- the selection afterwards, which could undo what event handlers do. events.connect(events.UPDATE_UI, emit_after_replace_text) diff --git a/core/ui.lua b/core/ui.lua index b006c84a..c8266775 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -375,10 +375,7 @@ 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() - 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) +events.connect(events.BUFFER_AFTER_REPLACE_TEXT, restore_buffer_state) -- Updates titlebar and statusbar. local function update_bars() diff --git a/test/test.lua b/test/test.lua index 05084c20..54419eb9 100644 --- a/test/test.lua +++ b/test/test.lua @@ -2144,7 +2144,7 @@ function test_editing_filter_through() textadept.editing.filter_through('sort') assert_equal(buffer:get_text(), '3|baz\n1|foo\n1|foo\n4|quux\n5|foobar\n2|bar\n') buffer:undo() - -- Test multiple selection. + -- Test rectangular selection. buffer:set_text('987654321\n123456789\n') buffer.rectangular_selection_anchor = 4 buffer.rectangular_selection_caret = 17 @@ -2154,8 +2154,9 @@ function test_editing_filter_through() assert_equal(buffer.rectangular_selection_caret, 17) buffer:undo() assert_equal(buffer:get_text(), '987654321\n123456789\n') - -- Test rectangular selection. + -- Test multiple selection. buffer:set_text('foo\n\tfoo\n\t\tfoo\nfoo') + buffer:goto_pos(1) textadept.editing.select_word() textadept.editing.select_word() textadept.editing.select_word() |