-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Describe the bug
minpac#update() alters 'cpo'.
To Reproduce
Run this shell command:
vim -Nu NONE -S <(cat <<'EOF'
vim9script
set pp=/tmp/.vim rtp=/tmp/.vim
delete('/tmp/.vim', 'rf')
system('git clone https://github.com/k-takata/minpac.git /tmp/.vim/pack/minpac/opt/minpac')
packadd minpac
minpac#init()
minpac#add('k-takata/minpac', {type: 'opt'})
set cpo=BceFsMny>
var cpo = &cpo
minpac#update()
timer_start(1'000, (_) => {
echom 'cpo BEFORE #update(): ' .. cpo
echom 'cpo AFTER #update(): ' .. &cpo
})
EOF
)
Wait for minpac#update() to finish, then run :mess to read the messages.
This is printed:
cpo BEFORE #update(): BceFsMny>
cpo AFTER #update(): aABceFs
Expected behavior
This is printed:
cpo BEFORE #update(): BceFsMny>
cpo AFTER #update(): BceFsMny>
Because minpac should not alter the value of 'cpo' as set by the user.
Environment
- Vim version: 8.2 Included patches: 1-2772
- OS: Ubuntu 16.04.7 LTS
- Terminal: xterm(367)
Additional context
I think the issue comes from autoload/minpac/job.vim which resets 'cpo' to its default Vim value, without restoring it at the end. Considering that no other other script in minpac resets 'cpo', I guess those 2 lines should be removed:
diff --git a/autoload/minpac/job.vim b/autoload/minpac/job.vim
index 219fabc..f6d7a86 100644
--- a/autoload/minpac/job.vim
+++ b/autoload/minpac/job.vim
@@ -24,9 +24,6 @@
" SOFTWARE.
" }}}
-let s:save_cpo = &cpo
-set cpo&vim
-
let s:jobidseq = 0
let s:jobs = {} " { job, opts, type: 'vimjob|nvimjob'}
let s:job_type_nvimjob = 'nvimjob'If, for some reason, 'cpo' really need to be temporarily reset to its default value, then it should be restored at the end:
diff --git a/autoload/minpac/job.vim b/autoload/minpac/job.vim
index 219fabc..ec17d38 100644
--- a/autoload/minpac/job.vim
+++ b/autoload/minpac/job.vim
@@ -263,3 +263,5 @@ function! minpac#job#wait(jobids, ...) abort
return s:job_wait(a:jobids, l:timeout)
endfunction
" }}}
+let &cpo = s:save_cpo
+unlet! s:save_cpoMetadata
Metadata
Assignees
Labels
No labels