Skip to content

Commit

Permalink
Merge pull request #1956 from timbrel/other-views
Browse files Browse the repository at this point in the history
Include sheets from split views in `visible_views`
  • Loading branch information
kaste authored Nov 27, 2024
2 parents 0bd255f + 60486be commit 13cbaea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
10 changes: 3 additions & 7 deletions core/commands/log_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
join_regions,
line_distance,
replace_view_content,
show_region
show_region,
visible_views
)
from ..ui_mixins.input_panel import show_single_line_input_panel
from ..ui_mixins.quick_panel import show_branch_panel
Expand Down Expand Up @@ -716,12 +717,7 @@ def on_status_update(repo_path, state):
def on_status_update_(repo_path, repo_is_dirty):
# type: (str, Optional[bool]) -> None
global drawn_graph_statuses, head_commit_seen
visible_views = filter_(
window.active_view_in_group(group)
for window in sublime.windows()
for group in range(window.num_groups())
)
for view in visible_views:
for view in visible_views():
if not head_commit_seen.get(view):
# `gs_log_graph_refresh` is running and has not yet processed HEAD,
# no need to start all over again.
Expand Down
13 changes: 8 additions & 5 deletions core/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,14 @@ def other_visible_views(view: sublime.View) -> Iterator[sublime.View]:
yield view_


def visible_views(window: sublime.Window) -> Iterator[sublime.View]:
num_groups = window.num_groups()
for group_id in range(num_groups):
if (view := window.active_view_in_group(group_id)):
yield view
def visible_views(window: sublime.Window = None) -> Iterator[sublime.View]:
yield from (
sheets_view
for window_ in ([window] if window else sublime.windows())
for group_id in range(window_.num_groups())
for sheet in window_.selected_sheets_in_group(group_id)
if (sheets_view := sheet.view())
)


# `replace_view_content` is a wrapper for `_replace_region` to get some
Expand Down
2 changes: 2 additions & 0 deletions stubs/sublime.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ class Window:
def set_view_index(self, view: View, group: int, idx: int) -> None: ...
def sheets(self) -> List[Sheet]: ...
def views(self) -> List[View]: ...
def selected_sheets(self) -> List[Sheet]: ...
def selected_sheets_in_group(self, group: int) -> List[Sheet]: ...
def active_sheet_in_group(self, group: int) -> Optional[Sheet]: ...
def active_view_in_group(self, group: int) -> Optional[View]: ...
def sheets_in_group(self, group: int) -> List[Sheet]: ...
Expand Down

0 comments on commit 13cbaea

Please sign in to comment.