Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit log history views #1963

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions core/commands/line_history.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from functools import partial
from itertools import chain
import os
import random

import sublime
from sublime_plugin import TextCommand, WindowCommand

from . import diff
from . import inline_diff
from .log_graph import busy_indicator
from .navigate import GsNavigate
from ..fns import filter_, pairwise
from ..git_command import GitCommand
Expand Down Expand Up @@ -263,8 +265,15 @@ def render():
]
+ [commit]
)
for line in self.git_streaming(*cmd):
replace_view_content(view, line, sublime.Region(view.size()))
with busy_indicator(view):
for line in self.git_streaming(*cmd):
replace_view_content(view, line, sublime.Region(view.size()))
if random.random() < 0.001:
if not view.is_valid():
break
if view.size() > 500_000:
replace_view_content(view, "\n...\n", sublime.Region(view.size()))
break

run_on_new_thread(render)

Expand Down
14 changes: 12 additions & 2 deletions core/commands/log_graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import deque
from contextlib import contextmanager
from dataclasses import dataclass
from functools import lru_cache, partial
from itertools import chain, count, groupby, islice
Expand Down Expand Up @@ -636,10 +637,19 @@ class BusyIndicatorConfig:
indicators: Sequence[str]


STATUS_BUSY_KEY = "gitsavvy-x-repo-status"
STATUS_BUSY_KEY = "gitsavvy-x-is-busy"
running_busy_indicators: Dict[Tuple[sublime.View, str], BusyIndicatorConfig] = {}


@contextmanager
def busy_indicator(view: sublime.View, status_key: str = STATUS_BUSY_KEY, **options):
start_busy_indicator(view, status_key, **options)
try:
yield
finally:
stop_busy_indicator(view, status_key)


def start_busy_indicator(
view: sublime.View,
status_key: str = STATUS_BUSY_KEY,
Expand Down Expand Up @@ -680,7 +690,7 @@ def _busy_indicator(view: sublime.View, status_key: str, start_time: float) -> N
else:
view.erase_status(status_key)

if elapsed < config.timeout_after:
if elapsed < config.timeout_after and view.is_valid():
sublime.set_timeout(
lambda: _busy_indicator(view, status_key, start_time),
config.cycle_time
Expand Down
Loading