Created by: int3
This is a fairly large pull request, so I'll try my best to explain how it came about.
I have a tendency to make typos at the command line, and I wished autojump could make a best guess despite these typos. This is how I implemented it: if autojump turns up no matches when it does a simple substring search, it tries again by ranking the list of directories by edit distance. A directory is only considered as a candidate if it is at an edit distance of 2 or less.
As edit distance algorithms are fairly slow creatures, I wrote a short script to profile autojump's performance. In the course of doing so I found a fairly big bottleneck in the code -- os.path.realpath
was being called unnecessarily often. After I factored it out, autojump did its completions in about 80% less time.
After I added in the edit distance ranking, these timings jumped back up by about the same amount. So autojump should not be much slower than it was originally if the user makes a typo. On the other hand, if autojump manages to find a match via simple substring matching, it should retain that 80% speedup.
The profiling code has to be run from the project root as 'python profile/profile.py [outfile]`. It measures the time taken to create completions for patterns of length 1-10. It's somewhat kludgey code, so if you'd rather not include it, I'd be happy to edit it out of this pull request.