Skip to content

Commit

Permalink
Merge pull request #1963 from timbrel/limit-log-history
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste authored Dec 25, 2024
2 parents 4d2e0df + 774e89a commit 10302fc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
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

0 comments on commit 10302fc

Please sign in to comment.