Skip to content

Commit 490a9af

Browse files
committed
restore cursor positions and focus when unhiding input panel
1 parent b5649f6 commit 490a9af

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sublime_input_view.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
class RequestViewInputCommand(RequestInputCommand): # this command should be overidden, and not used directly
88
"""Create an input panel specific to the view that this command was run on (by default, Sublime's API makes it apply to the whole window)."""
99
input_panel_hidden = None
10+
last_selections = None
1011

1112
def parse_args(self):
1213
super().parse_args()
@@ -23,11 +24,16 @@ def show_input_panel(self, initial_value):
2324

2425
def hide_input_panel(self):
2526
self.input_panel_hidden = True
27+
self.last_selections = [cursor for cursor in self.input_panel.sel()]
2628
self.close_input_panel()
2729

2830
def restore_input_panel(self):
2931
self.current_value = None
3032
self.show_input_panel(self.pending_value)
33+
if self.last_selections is not None:
34+
self.input_panel.sel().clear()
35+
self.input_panel.sel().add_all(self.last_selections)
36+
self.input_panel.window().focus_view(self.input_panel)
3137

3238
def on_activated_async(self, view):
3339
if view is None:

0 commit comments

Comments
 (0)