From 1cbe220e6f00a125d266eaec083abc2b77f82ed5 Mon Sep 17 00:00:00 2001 From: bismarckhsu Date: Wed, 16 Nov 2016 11:17:23 +0800 Subject: [PATCH] Fix jump error when exiting char mode without entering target --- ace_jump.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ace_jump.py b/ace_jump.py index 2034a61..ec5182a 100644 --- a/ace_jump.py +++ b/ace_jump.py @@ -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 @@ -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)] @@ -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"""