You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is an immediate consequence of jump_back and jump_forward does not record most actions #2959 As now, every change to the selections is creating a new history entry, running jump_back after using find_under_expand a few times, always focus on the first selection, instead of the latest selection focused by find_under_expand:
By also restoring the viewport position, we can always correctly focus on the latest selection from find_under_expand. However, if the buffer changed its size, (file reloading), then all saved viewport positions would be unsynchronized with the new buffer size.
Then, a suggestion would be to add support for add_regions to update saved regions and also update the saved viewport position, when the buffer changes.
Suggested patch for restoring the viewport position instead of running view.show(selections[0])
--- a/history_list.py+++ b/history_list.py@@ -43,7 +43,7 @@ class JumpHistory():
# check the newest entry is not the same as selection
if self.history_list != []:
- first_view, first_key = self.history_list[-1]+ first_view, first_key, viewport = self.history_list[-1]
if first_view.view_id == view.view_id:
first_sel = view.get_regions(first_key)
if first_sel == region_list:
@@ -53,7 +53,7 @@ class JumpHistory():
view.add_regions(key, region_list)
# set the new selection as the current item, as a tuple (view_id, key)
- self.history_list.append((view, key))+ self.history_list.append((view, key, view.viewport_position()))
self.trim_selections()
def jump_back(self, active_view):
@@ -73,24 +73,24 @@ class JumpHistory():
if self.current_item == -len(self.history_list):
# already pointing to the oldest
- return None, []+ return None, [], None
# get the next (older) selection
self.current_item -= 1
- view, key = self.history_list[self.current_item]- return view, view.get_regions(key)+ view, key, viewport = self.history_list[self.current_item]+ return view, view.get_regions(key), viewport
def jump_forward(self, active_view):
if self.history_list == []:
- return None, []+ return None, [], None
# already pointing to the front
if self.current_item >= -1:
- return None, []+ return None, [], None
# get the top selection
# print(self.current_item)
self.current_item += 1
- view, key = self.history_list[self.current_item]- return view, view.get_regions(key)+ view, key, viewport = self.history_list[self.current_item]+ return view, view.get_regions(key), viewport
def remove_view(self, view_id):
i = 0
@@ -118,7 +118,7 @@ class JumpHistory():
# remove all history that are newer than current
for i in range(-1, self.current_item):
- view, key = self.history_list[i]+ view, key, viewport = self.history_list[i]
view.erase_regions(key)
del self.history_list[self.current_item + 1:]
# set current_item to the imaginary back (current caret position not yet pushed)
@@ -130,7 +130,7 @@ class JumpHistory():
# trim to a smaller size to avoid doing on this every insert
for i in range(0, len(self.history_list) - self.LIST_TRIMMED_SIZE):
# erase the regions from view
- view, key = self.history_list[i]+ view, key, viewport = self.history_list[i]
view.erase_regions(key)
del self.history_list[: len(self.history_list) - self.LIST_TRIMMED_SIZE]
@@ -237,7 +237,7 @@ class JumpBackCommand(sublime_plugin.TextCommand):
# get the new selection
jump_history = get_jump_history_for_view(self.view)
- view, region_list = jump_history.jump_back(self.view)+ view, region_list, viewport = jump_history.jump_back(self.view)
if region_list == []:
sublime.status_message("Already at the earliest position")
return
@@ -250,7 +250,10 @@ class JumpBackCommand(sublime_plugin.TextCommand):
self.view.window().focus_view(view)
view.sel().clear()
view.sel().add_all(region_list)
- view.show(region_list[0], True)+ # print( region_list )+ # view.show(region_list[0], True)+ view.set_viewport_position( viewport, True )+
sublime.status_message("")
unlock_jump_history()
@@ -267,7 +270,7 @@ class JumpForwardCommand(sublime_plugin.TextCommand):
# jump back in history
# get the new selection
jump_history = get_jump_history_for_view(self.view)
- view, region_list = jump_history.jump_forward(self.view)+ view, region_list, viewport = jump_history.jump_forward(self.view)
if region_list == []:
sublime.status_message("Already at the newest position")
return
@@ -281,7 +284,8 @@ class JumpForwardCommand(sublime_plugin.TextCommand):
view.sel().clear()
view.sel().add_all(region_list)
# print(region_list)
- view.show(region_list[0], True)+ # view.show(region_list[0], True)+ view.set_viewport_position( viewport, True )
sublime.status_message("")
unlock_jump_history()
I don't see a need for this, personally. When I jump back to where I was, I'm perfectly fine with having that region in the center of my view where it gets my immediate attention rather than cycling through old viewport positions that a) might have changed through edits and b) I don't remember anyway.
That said, I do seldomly use these commands.
Also, a gigantic 24-item "related" list doesn't exactly help because the signal to noise ratio is too low. The only directly related issue I could extract from your issue description seems to be #2959. All the others are maginally related at best and sometimes only because they also use View.show internally or just involve viewports.
I don't see a need for this, personally. When I jump back to where I was
With the current implementation for history_input, there will be no problem as you describe. But after add the #2959 feature, it will not work right as now because there will be multiple selections when jumping back/forth, and always focusing on the first selection, will hide the actual last selection when they spread across several pages.
at best and sometimes only because they also use View.show internally or just involve viewport
Yeah, as I suggested:
Then, a suggestion would be to add support for add_regions to update saved regions and also update the saved viewport position, when the buffer changes.
These bugs are related to the view centering implementation.
This won't work, since it won't deal with modifications to the buffer between jumping around. That is the reason we use add_regions() instead of tracking the selection in a Python object, like was proposed in #2963.
Description
This issue is an immediate consequence of
jump_back
andjump_forward
does not record most actions #2959 As now, every change to the selections is creating a new history entry, runningjump_back
after usingfind_under_expand
a few times, always focus on the first selection, instead of the latest selection focused byfind_under_expand
:By also restoring the viewport position, we can always correctly focus on the latest selection from
find_under_expand
. However, if the buffer changed its size, (file reloading), then all saved viewport positions would be unsynchronized with the new buffer size.Then, a suggestion would be to add support for
add_regions
to update saved regions and also update the saved viewport position, when the buffer changes.Suggested patch for restoring the
viewport
position instead of runningview.show(selections[0])
Environment
10 build 15063 x64
1920x1080
1.0
3207
Related Threads
jump_back
andjump_forward
does not record most actionsjump_back
andjump_forward
does not record most actions #2959add_regions
for tracking history Increase jump history size from 100 to 1000 and stop usingadd_regions
for tracking history #2963output.exec
panel view cursor and scroll position after building a project Restore theoutput.exec
panel view cursor and scroll position after building a project #2547output.exec
panel view cursor and scroll position after building a project Restore theoutput.exec
panel view cursor and scroll position after building a project #2547Ctrl+K, Ctrl+D
to skip item, does not skip the item and selects wrong items CallingCtrl+K, Ctrl+D
to skip item, does not skip the item and selects wrong items #2091The text was updated successfully, but these errors were encountered: