Skip to content

Commit

Permalink
Ensure debounced function runs on UI thread
Browse files Browse the repository at this point in the history
  • Loading branch information
jwortmann committed Dec 20, 2023
1 parent 7b65fb2 commit dff0050
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugin/core/input_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def debounced(user_function: Callable[P, Any]) -> Callable[P, None]:

@functools.wraps(user_function)
def wrapped_function(*args: P.args, **kwargs: P.kwargs) -> None:
def call_function():
def call_function() -> None:
if hasattr(wrapped_function, '_timer'):
delattr(wrapped_function, '_timer')
return user_function(*args, **kwargs)
sublime.set_timeout(lambda: user_function(*args, **kwargs))
timer = getattr(wrapped_function, '_timer', None)
if timer is not None:
timer.cancel()
Expand Down

0 comments on commit dff0050

Please sign in to comment.