Don't be too smart when restoring vim session

A user may decide to use custom session file. Eg vim -S Session1.vim
With the previous approach we were preventing that as we only checked
for the existence of the default Session.vim file.
This commit is contained in:
Bruno Sutic 2020-06-05 09:21:51 +02:00
parent 327c0481ad
commit bd671b83dc
No known key found for this signature in database
GPG Key ID: CAFA7B1B2914ED81
2 changed files with 2 additions and 9 deletions

View File

@ -26,6 +26,8 @@
- always use `-ao` flags for `ps` command to detect commands
- Deprecate restoring shell history feature.
- `view` added to the list of automatically restored programs
- Enable vim session strategy to work with custom session files,
e.g. `vim -S Session1.vim`.
### v2.4.0, 2015-02-23
- add "tmux-test"

View File

@ -13,18 +13,9 @@ vim_session_file_exists() {
[ -e "${DIRECTORY}/Session.vim" ]
}
original_command_contains_session_flag() {
[[ "$ORIGINAL_COMMAND" =~ "-S" ]]
}
main() {
if vim_session_file_exists; then
echo "vim -S"
elif original_command_contains_session_flag; then
# Session file does not exist, yet the original vim command contains
# session flag `-S`. This will cause an error, so we're falling back to
# starting plain vim.
echo "vim"
else
echo "$ORIGINAL_COMMAND"
fi