Expand more when performing history path detection

When adding a command to history, we first expand its arguments to see
if any arguments are paths which refer to files. If so, we will only
autosuggest that command from history if the files are still valid. For
example, if the user runs `rm ./file.txt` then we will remember that
`./file.txt` referred to a file, and then only autosuggest that if the file
is present again.

Prior to this change we only performed simple expansion relative to the
working directory. This change extends it to variables and tilde
expansion. For example we will now apply the same hinting for
`rm ~/file.txt`

Fixes #7582
This commit is contained in:
ridiculousfish
2020-12-31 13:30:58 -08:00
parent e93996dc01
commit bee8e8f6f7
6 changed files with 70 additions and 36 deletions

View File

@@ -3241,7 +3241,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} else {
mode = history_persistence_mode_t::disk;
}
history->add_pending_with_file_detection(text, vars.get_pwd_slash(), mode);
history->add_pending_with_file_detection(text, vars.snapshot(), mode);
}
rls.finished = true;