Skip to content

Commit db9e26a

Browse files
committed
Fixed potential crash when manually emitting events.UPDATE_UI without an argument.
Raising an error results in an infinite loop, so just silently exit the handler.
1 parent dbcd91c commit db9e26a

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

core/ui.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ events.connect(events.APPLEEVENT_ODOC,
302302

303303
-- Sets buffer statusbar text.
304304
events.connect(events.UPDATE_UI, function(updated)
305-
if updated & 3 == 0 then return end -- ignore scrolling
305+
if not updated or updated & 3 == 0 then return end -- ignore scrolling
306306
local text = not CURSES and '%s %d/%d %s %d %s %s %s %s' or
307307
'%s %d/%d %s %d %s %s %s %s'
308308
local pos = buffer.current_pos

modules/textadept/editing.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ end, 1)
551551

552552
-- Highlights matching braces.
553553
events.connect(events.UPDATE_UI, function(updated)
554-
if updated & 3 == 0 then return end -- ignore scrolling
554+
if not updated or updated & 3 == 0 then return end -- ignore scrolling
555555
if brace_matches[buffer.char_at[buffer.current_pos]] then
556556
local match = buffer:brace_match(buffer.current_pos, 0)
557557
local f = match ~= -1 and view.brace_highlight or view.brace_bad_light
@@ -563,7 +563,7 @@ end)
563563

564564
-- Highlight all instances of the current or selected word.
565565
events.connect(events.UPDATE_UI, function(updated)
566-
if updated & buffer.UPDATE_SELECTION == 0 or ui.find.active then return end
566+
if not updated or updated & buffer.UPDATE_SELECTION == 0 or ui.find.active then return end
567567
if M.highlight_words == M.HIGHLIGHT_NONE then return end
568568
buffer.indicator_current = M.INDIC_HIGHLIGHT
569569
buffer:indicator_clear_range(1, buffer.length)

modules/textadept/menu.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ local function deselect()
2424
buffer:set_empty_selection(buffer._deselect_pos)
2525
end
2626
events.connect(events.UPDATE_UI, function(updated)
27-
if updated & 3 > 0 and buffer.selection_empty then buffer._deselect_pos = buffer.current_pos end
27+
if not updated or updated & 3 == 0 or not buffer.selection_empty then return end
28+
buffer._deselect_pos = buffer.current_pos
2829
end)
2930
--- Wrapper around `buffer:upper_case()` and `buffer:lower_case()`.
3031
local function change_case(upper)

modules/textadept/snippets.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ setmetatable(M,
747747
-- Update snippet transforms when text is added or deleted.
748748
events.connect(events.UPDATE_UI, function(updated)
749749
if not active_snippet then return end
750-
if updated & buffer.UPDATE_CONTENT > 0 then active_snippet:update_transforms() end
750+
if updated and updated & buffer.UPDATE_CONTENT > 0 then active_snippet:update_transforms() end
751751
if #keys.keychain == 0 then ui.statusbar_text = _L['Snippet active'] end
752752
end)
753753

0 commit comments

Comments
 (0)