Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f75d39c

Browse files
committed
Workaround empty space sometimes remaining when BlameAll phantoms are erased
1 parent 55f2811 commit f75d39c

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

‎src/blame_all.py‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
class BlameShowAll(BaseBlame, sublime_plugin.TextCommand):
1616

17+
HORIZONTAL_SCROLL_DELAY_MS = 100
18+
1719
# Overrides --------------------------------------------------
1820

1921
def __init__(self, view):
@@ -34,6 +36,9 @@ def run(self, edit):
3436
self.phantom_set.update(phantoms)
3537
self.view.settings().erase(VIEW_SETTING_PHANTOM_ALL_DISPLAYED)
3638
self.view.run_command("blame_restore_rulers")
39+
# Workaround a visible empty space sometimes remaining in the viewport.
40+
self.horizontal_scroll_to_limit(left=False)
41+
self.horizontal_scroll_to_limit(left=True)
3742
return
3843

3944
try:
@@ -75,12 +80,7 @@ def run(self, edit):
7580
self.view.settings().set(VIEW_SETTING_PHANTOM_ALL_DISPLAYED, True)
7681
self.store_rulers()
7782
# Bring the phantoms into view without the user needing to manually scroll left.
78-
sublime.set_timeout(
79-
lambda: self.view.set_viewport_position(
80-
(0.0, self.view.viewport_position()[1])
81-
),
82-
0,
83-
)
83+
self.horizontal_scroll_to_limit(left=True)
8484

8585
def _view(self):
8686
return self.view
@@ -104,6 +104,15 @@ def store_rulers(self):
104104
)
105105
self.view.settings().set(VIEW_SETTING_RULERS, [])
106106

107+
def horizontal_scroll_to_limit(self, *, left):
108+
x = 0.0 if left else self.view.layout_extent()[0]
109+
y = self.view.viewport_position()[1]
110+
# NOTE: The scrolling doesn't seem to work if called inline (or with a 0ms timeout).
111+
sublime.set_timeout(
112+
lambda: self.view.set_viewport_position((x, y)),
113+
self.HORIZONTAL_SCROLL_DELAY_MS,
114+
)
115+
107116

108117
class BlameEraseAll(sublime_plugin.TextCommand):
109118

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /