Favor execute() over :redir to minimize side effects

If this is still unacceptable for users of ancient versions of Vim, we
could further change the else clause to `return 1`.

Resolves: https://github.com/tpope/vim-sensible/issues/182
This commit is contained in:
Tim Pope
2023-01-03 11:52:22 -05:00
parent eb59f45508
commit 8e274c23e4

View File

@@ -21,9 +21,13 @@ endif
" overriding options in the user's vimrc, but still override options in the
" system vimrc.
function! s:MaySet(option) abort
redir => out
silent verbose execute 'setglobal' a:option . '?'
redir END
if exists('*execute')
let out = execute('verbose setglobal ' . a:option . '?')
else
redir => out
silent verbose execute 'setglobal' a:option . '?'
redir END
endif
return out !~# ' \~[\/]'
endfunction