diff --git a/plugin/listener.py b/plugin/listener.py index 09974c14..e5b96c4d 100644 --- a/plugin/listener.py +++ b/plugin/listener.py @@ -78,7 +78,7 @@ def names_as_str(items: Iterable[Any], *, sep: str = ", ") -> str: def _configured_debounce(func: _T_Callable) -> _T_Callable: """Debounce a function so that it's called once in seconds.""" - def debounced(*args: Any, **kwargs: Any) -> None: + def debounced(*args: Any, **kwargs: Any) -> Any: if (time_s := get_merged_plugin_setting("debounce", 0)) > 0: return debounce(time_s)(func)(*args, **kwargs) return func(*args, **kwargs) diff --git a/plugin/utils.py b/plugin/utils.py index cc996b1f..0559819e 100644 --- a/plugin/utils.py +++ b/plugin/utils.py @@ -323,7 +323,11 @@ def list_all_views(*, include_transient: bool = False) -> Generator[sublime.View def get_view_by_id(id: int) -> sublime.View | None: - return first_true(list_all_views(include_transient=True), pred=lambda view: view.id() == id) + return view if (view := sublime.View(id)).is_valid() else None + + +def get_window_by_id(id: int) -> sublime.Window | None: + return window if (window := sublime.Window(id)).is_valid() else None def head_tail_content(content: str, partial: int) -> str: