Skip to content

Commit

Permalink
Correctly restore selection in two-step text commands
Browse files Browse the repository at this point in the history
  • Loading branch information
wadetb committed Nov 6, 2016
1 parent ee5a9a3 commit 41bd4f2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions csvplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def SelectColumn(self, column_index, view):
region = sublime.Region(a, b)
view.sel().add(region)

def SaveSelection(self, view):
@staticmethod
def SaveSelection(view):
saved_selection = []

for region in view.sel():
Expand All @@ -183,7 +184,8 @@ def SaveSelection(self, view):

return saved_selection

def RestoreSelection(self, view, saved_selection):
@staticmethod
def RestoreSelection(view, saved_selection):
view.sel().clear()

for rowcol_region in saved_selection:
Expand Down Expand Up @@ -514,8 +516,11 @@ def Evaluate(self):

class CsvSetOutputCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
if args['output'] != None:
if 'output' in args:
self.view.replace(edit, sublime.Region(0, self.view.size()), args['output']);

if 'saved_selection' in args:
CSVMatrix.RestoreSelection(self.view, args['saved_selection'])

class CsvSortByColAscCommand(sublime_plugin.TextCommand):
def run(self, edit):
Expand Down

0 comments on commit 41bd4f2

Please sign in to comment.