Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jump error when exiting char mode without entering target #53

Merged
merged 1 commit into from
Nov 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ace_jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def submit(self):
self.remove_labels()
set_views_sel(self.all_views, self.sel)
set_views_syntax(self.all_views, self.syntax)
self.jump(self.labels.find(self.target))

if self.valid_target(self.target):
self.jump(self.labels.find(self.target))

mode = 0
ace_jump_active = False
Expand Down Expand Up @@ -209,8 +211,6 @@ def remove_labels(self):

def jump(self, index):
"""Performs the jump action"""
if self.target == "" or index < 0 or index >= last_index:
return

region = hints[index].begin()
view = self.changed_views[self.view_for_index(index)]
Expand All @@ -234,6 +234,13 @@ def view_for_index(self, index):
if index < breakpoint:
return self.breakpoints.index(breakpoint)

def valid_target(self, target):
"""Check if jump target is valid"""

index = self.labels.find(target)

return target != "" and index >= 0 and index < last_index;

class AceJumpWordCommand(AceJumpCommand):
"""Specialized command for word-mode"""

Expand Down