Summary
When the autojump database contains paths that no longer exist on disk, selecting a numbered entry from tab completion jumps to the wrong directory. The tab menu and the jump resolution use different filtering, causing indices to shift.
Root Cause
handle_tab_completion generates the tab menu and resolves tab indices using find_matches(..., check_entries=False), which includes non-existent directories in the results. But when the user selects an entry by number, main() resolves the index using find_matches(..., check_entries=True) (the default), which filters out non-existent directories.
This means a deleted directory can occupy a slot in the menu (e.g., position 2), but the jump skips over it, so position 2 now resolves to what was position 3 in the menu.
Steps to Reproduce
- Visit several directories so they're recorded in the autojump database
- Delete one or more of those directories from disk (don't run
autojump --purge)
- Type
j <needle><tab> where the needle matches the deleted directory along with other existing ones
- Note the numbered list shown
- Select an entry whose number comes after a deleted directory's position
- Observe that autojump jumps to a different directory than the one shown at that position
Example
With a deleted path at position 2 in the menu:
| Menu position |
Menu shows |
Jump actually goes to |
| 1 |
/path/to/foo (exists) |
/path/to/foo (correct) |
| 2 |
/path/to/deleted-bar (missing) |
/path/to/baz (wrong!) |
| 3 |
/path/to/baz (exists) |
/path/to/qux (wrong!) |
Fix
Change handle_tab_completion to use check_entries=True (the default) in all three find_matches calls, matching the behavior in main(). This ensures non-existent paths are excluded from both the tab menu and the jump resolution, keeping indices consistent.
Workaround
Running autojump --purge removes non-existent paths from the database, which eliminates the index mismatch until more paths are deleted.
Summary
When the autojump database contains paths that no longer exist on disk, selecting a numbered entry from tab completion jumps to the wrong directory. The tab menu and the jump resolution use different filtering, causing indices to shift.
Root Cause
handle_tab_completiongenerates the tab menu and resolves tab indices usingfind_matches(..., check_entries=False), which includes non-existent directories in the results. But when the user selects an entry by number,main()resolves the index usingfind_matches(..., check_entries=True)(the default), which filters out non-existent directories.This means a deleted directory can occupy a slot in the menu (e.g., position 2), but the jump skips over it, so position 2 now resolves to what was position 3 in the menu.
Steps to Reproduce
autojump --purge)j <needle><tab>where the needle matches the deleted directory along with other existing onesExample
With a deleted path at position 2 in the menu:
/path/to/foo(exists)/path/to/foo(correct)/path/to/deleted-bar(missing)/path/to/baz(wrong!)/path/to/baz(exists)/path/to/qux(wrong!)Fix
Change
handle_tab_completionto usecheck_entries=True(the default) in all threefind_matchescalls, matching the behavior inmain(). This ensures non-existent paths are excluded from both the tab menu and the jump resolution, keeping indices consistent.Workaround
Running
autojump --purgeremoves non-existent paths from the database, which eliminates the index mismatch until more paths are deleted.