Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minpac#update() alters 'cpo' #131

Closed
lacygoill opened this issue Apr 16, 2021 · 0 comments · Fixed by #136 · May be fixed by #134
Closed

minpac#update() alters 'cpo' #131

lacygoill opened this issue Apr 16, 2021 · 0 comments · Fixed by #136 · May be fixed by #134

Comments

@lacygoill
Copy link

lacygoill commented Apr 16, 2021

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_cpo
k-takata added a commit that referenced this issue Apr 21, 2021
@k-takata k-takata mentioned this issue Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant