Skip to content

Commit

Permalink
restore cursor positions and focus when unhiding input panel
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall committed Feb 17, 2016
1 parent b5649f6 commit 490a9af
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sublime_input_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class RequestViewInputCommand(RequestInputCommand): # this command should be overidden, and not used directly
"""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)."""
input_panel_hidden = None
last_selections = None

def parse_args(self):
super().parse_args()
Expand All @@ -23,11 +24,16 @@ def show_input_panel(self, initial_value):

def hide_input_panel(self):
self.input_panel_hidden = True
self.last_selections = [cursor for cursor in self.input_panel.sel()]
self.close_input_panel()

def restore_input_panel(self):
self.current_value = None
self.show_input_panel(self.pending_value)
if self.last_selections is not None:
self.input_panel.sel().clear()
self.input_panel.sel().add_all(self.last_selections)
self.input_panel.window().focus_view(self.input_panel)

def on_activated_async(self, view):
if view is None:
Expand Down

0 comments on commit 490a9af

Please sign in to comment.