Skip to content

Commit a6ab1a3

Browse files
jwortmannrwols
authored andcommitted
Restore selections after location picker panel
1 parent 9fa725a commit a6ab1a3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

plugin/locationpicker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(
5353
side_by_side: bool
5454
) -> None:
5555
self._view = view
56+
self._view_states = ([r.to_tuple() for r in view.sel()], view.viewport_position())
5657
window = view.window()
5758
if not window:
5859
raise ValueError("missing window")
@@ -76,6 +77,9 @@ def _unpack(self, index: int) -> Tuple[Optional[Session], Union[Location, Locati
7677
return self._weaksession(), location, uri, position
7778

7879
def _select_entry(self, index: int) -> None:
80+
if self._view.is_valid() and not self._side_by_side:
81+
self._view.set_viewport_position(self._view_states[1])
82+
self._view.run_command('lsp_selection_set', {'regions': self._view_states[0]})
7983
if index >= 0 and self._view.is_valid():
8084
session, location, uri, position = self._unpack(index)
8185
if not session:

0 commit comments

Comments
 (0)