Skip to content

Commit

Permalink
Merge pull request #1931 from timbrel/sparse-re-renders
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Jun 17, 2024
2 parents 9351e2e + 6b87765 commit 8a3d60d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion common/ui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from contextlib import contextmanager
from copy import deepcopy
from functools import wraps
Expand Down Expand Up @@ -343,10 +344,15 @@ def render(self):
self.refresh_view_state()
self.just_render()

@distinct_until_state_changed
# We check twice if a re-render is actually necessary because the state has grown
# and invalidates when formatted relative dates change, t.i., too often.
@distinct_until_state_changed # <== 1st check data/state
def just_render(self):
# type: () -> None
content, regions = self._render_template()
if content == self.view.substr(sublime.Region(0, self.view.size())): # <== 2nd check actual view content
return

with self.keep_cursor_on_something():
self.draw(self.title(), content, regions)

Expand Down

0 comments on commit 8a3d60d

Please sign in to comment.