Skip to content

Commit

Permalink
refactor: tidy codes
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng committed Feb 26, 2024
1 parent b55a67b commit d6154b3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d6154b3

Please sign in to comment.