Skip to content

Commit

Permalink
fixed error opening the jump window
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuelfomberg committed Jul 15, 2014
1 parent ec54aa7 commit 51ef133
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions perlidx.py
Expand Up @@ -2,6 +2,14 @@

views = {}

def DisplayCurrentSub(view, subs, index, pos):
views[view.id()]['last'] = { 'index': index, 'pos': pos }

if index > -1:
view.set_status('perlsubs', '[PerlSub: '+subs[index][2]+']')
else:
view.set_status('perlsubs', '[PerlSub: <none>]')

def GetCurrentSub(view, subs):
pos = view.sel()[0].a
index = -1
Expand Down Expand Up @@ -29,12 +37,8 @@ def GetCurrentSub(view, subs):
index = index + 1
else:
break
views[view.id()]['last'] = { 'index': index, 'pos': pos }

if index > -1:
view.set_status('perlsubs', '[PerlSub: '+subs[index][2]+']')
else:
view.set_status('perlsubs', '[PerlSub: <none>]')

DisplayCurrentSub(view, subs, index, pos)

def IsPerl(view):
syntax = view.settings().get('syntax')
Expand Down Expand Up @@ -108,9 +112,12 @@ def run(self, edit):
subs = get_subs_list(view)
else:
subs = views[view.id()]['subs']
if len(subs) > 0:
index = GetCurrentSub(view, subs)
view.window().show_quick_panel([s[0] for s in subs], self.jumpto, 0, index)
if len(subs) == 0:
return
if 'last' not in views[view.id()]:
GetCurrentSub(view, subs)
index = views[view.id()]['last']['index']
view.window().show_quick_panel([s[0] for s in subs], self.jumpto, 0, index)
def jumpto(self, arg):
if arg < 0:
return
Expand All @@ -121,7 +128,10 @@ def jumpto(self, arg):
else:
subs = views[view.id()]['subs']
rec = subs[arg]
view.show_at_center(rec[1])
pos = rec[1]
view.show_at_center(pos)
view.sel().clear()
view.sel().add(sublime.Region(rec[1], rec[1]))
view.sel().add(sublime.Region(pos, pos))
DisplayCurrentSub(view, subs, arg, pos)


0 comments on commit 51ef133

Please sign in to comment.