From 8e274c23e42744bc88d5583f7fa0c6eb8fb1c256 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 3 Jan 2023 11:52:22 -0500 Subject: [PATCH] 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 --- plugin/sensible.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugin/sensible.vim b/plugin/sensible.vim index d4ba37d..85d581b 100644 --- a/plugin/sensible.vim +++ b/plugin/sensible.vim @@ -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