mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
move match last pattern into separate funciton and disabled
This commit is contained in:
parent
31001c9456
commit
7343ef1825
36
bin/autojump
36
bin/autojump
@ -34,6 +34,7 @@ class Database:
|
|||||||
self.data = {}
|
self.data = {}
|
||||||
self.load()
|
self.load()
|
||||||
|
|
||||||
|
# TODO: increase logarithmically as opposed to linear
|
||||||
def add(self, key, increment = 1):
|
def add(self, key, increment = 1):
|
||||||
""" Increment existing paths or initialize new ones to 0. """
|
""" Increment existing paths or initialize new ones to 0. """
|
||||||
self.data[key] = self.data.get(key, 0.) + increment
|
self.data[key] = self.data.get(key, 0.) + increment
|
||||||
@ -207,6 +208,19 @@ def unico(text):
|
|||||||
else:
|
else:
|
||||||
return unicode(text)
|
return unicode(text)
|
||||||
|
|
||||||
|
def match_last(pattern):
|
||||||
|
""" If the last pattern contains a full path, jump there.
|
||||||
|
The regexp is because we need to support stuff like
|
||||||
|
"j wo jo__3__/home/joel/workspace/joel" for zsh. """
|
||||||
|
last_pattern_path = re.sub("(.*)"+COMPLETION_SEPARATOR, "", pattern[-1])
|
||||||
|
if (len(last_pattern_path) > 0 and
|
||||||
|
last_pattern_path[0] == "/" and
|
||||||
|
os.path.exists(last_pattern_path)):
|
||||||
|
if not ARGS.preserve:
|
||||||
|
output(last_pattern_path)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def match(path, pattern, ignore_case=False, only_end=False):
|
def match(path, pattern, ignore_case=False, only_end=False):
|
||||||
""" Check whether a path matches a particular pattern, and return
|
""" Check whether a path matches a particular pattern, and return
|
||||||
the remaining part of the string. """
|
the remaining part of the string. """
|
||||||
@ -250,24 +264,20 @@ def shell_utility():
|
|||||||
options()
|
options()
|
||||||
db = Database(DB_FILE)
|
db = Database(DB_FILE)
|
||||||
|
|
||||||
#userchoice is i if the pattern is __pattern__i, otherwise -1
|
# if no directories, add empty string
|
||||||
userchoice = -1
|
|
||||||
results = []
|
|
||||||
|
|
||||||
if (ARGS.directory == ''):
|
if (ARGS.directory == ''):
|
||||||
patterns = [unico('')]
|
patterns = [unico('')]
|
||||||
else:
|
else:
|
||||||
patterns = [decode(a) for a in ARGS.directory]
|
patterns = [decode(a) for a in ARGS.directory]
|
||||||
|
|
||||||
# If the last pattern contains a full path, jump there
|
# check last pattern for full path
|
||||||
# The regexp is because we need to support stuff like
|
# FIXME: disabled until tab completion is fixed on the shell side
|
||||||
# "j wo jo__3__/home/joel/workspace/joel" for zsh
|
# if match_last(patterns): return True
|
||||||
last_pattern_path = re.sub("(.*)"+COMPLETION_SEPARATOR, "", patterns[-1])
|
|
||||||
if (len(last_pattern_path)>0 and
|
#userchoice is i if the pattern is __pattern__i, otherwise -1
|
||||||
last_pattern_path[0] == "/" and
|
userchoice = -1
|
||||||
os.path.exists(last_pattern_path)):
|
results = []
|
||||||
if not ARGS.complete: output(last_pattern_path)
|
|
||||||
else:
|
|
||||||
#check for ongoing completion, and act accordingly
|
#check for ongoing completion, and act accordingly
|
||||||
endmatch = re.search(COMPLETION_SEPARATOR+"([0-9]+)", patterns[-1])
|
endmatch = re.search(COMPLETION_SEPARATOR+"([0-9]+)", patterns[-1])
|
||||||
if endmatch: #user has selected a completion
|
if endmatch: #user has selected a completion
|
||||||
|
Loading…
Reference in New Issue
Block a user