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

More aggressively check if a view needs a re-rendering #1931

Merged
merged 2 commits into from
Jun 17, 2024
Merged
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
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