Skip to content

Commit 13a6605

Browse files
MiguelBarrochrisbra
authored andcommitted
patch 9.1.0859: several problems with the GLVS plugin
Problem: several problems with the GLVS plugin Solution: fix issues, add regression tests, require at least Vim 9.1 (GuyBrush) closes: #16036 Signed-off-by: GuyBrush <miguel.barro@live.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 002ccbf commit 13a6605

4 files changed

Lines changed: 388 additions & 28 deletions

File tree

runtime/autoload/getscript.vim

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
" 2024 Sep 23 by Vim Project: runtime dir selection fix (#15722)
1212
" autoloading search path fix
1313
" substitution of hardcoded commands with global variables
14+
" 2024 Nov 12 by Vim Project: fix problems on Windows (#16036)
1415
" }}}
1516
"
1617
" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
@@ -27,9 +28,9 @@ if &cp
2728
echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
2829
finish
2930
endif
30-
if v:version < 702
31+
if v:version < 901
3132
echohl WarningMsg
32-
echo "***warning*** this version of GetLatestVimScripts needs vim 7.2"
33+
echo "***warning*** this version of GetLatestVimScripts needs vim 9.1"
3334
echohl Normal
3435
finish
3536
endif
@@ -57,6 +58,9 @@ endif
5758
if !exists("g:GetLatestVimScripts_wget")
5859
if executable("wget")
5960
let g:GetLatestVimScripts_wget= "wget"
61+
elseif executable("curl.exe")
62+
" enforce extension: windows powershell desktop version has a curl alias that hides curl.exe
63+
let g:GetLatestVimScripts_wget= "curl.exe"
6064
elseif executable("curl")
6165
let g:GetLatestVimScripts_wget= "curl"
6266
else
@@ -69,7 +73,7 @@ endif
6973
if !exists("g:GetLatestVimScripts_options")
7074
if g:GetLatestVimScripts_wget == "wget"
7175
let g:GetLatestVimScripts_options= "-q -O"
72-
elseif g:GetLatestVimScripts_wget == "curl"
76+
elseif g:GetLatestVimScripts_wget =~ "curl"
7377
let g:GetLatestVimScripts_options= "-s -o"
7478
else
7579
let g:GetLatestVimScripts_options= ""
@@ -121,11 +125,14 @@ if g:GetLatestVimScripts_allowautoinstall
121125
let s:dotvim= s:is_windows ? "vimfiles" : ".vim"
122126

123127
if !exists("g:GetLatestVimScripts_mv")
124-
if s:is_windows && &shell !~ '\cbash\|pwsh\|powershell'
128+
if &shell =~? '\<pwsh\>\|\<powershell\>'
129+
let g:GetLatestVimScripts_mv= "move -Force"
130+
elseif s:is_windows && &shell =~? '\<cmd\>'
125131
" windows (but not cygwin/bash)
126-
let g:GetLatestVimScripts_mv= "move"
132+
let g:GetLatestVimScripts_mv= "move /Y"
127133
else
128-
" unix
134+
" unix or cygwin bash/zsh
135+
" 'mv' overrides existing files without asking
129136
let g:GetLatestVimScripts_mv= "mv"
130137
endif
131138
endif
@@ -160,12 +167,6 @@ fun! getscript#GetLatestVimScripts()
160167
return
161168
endif
162169

163-
" insure that fnameescape() is available
164-
if !exists("*fnameescape")
165-
echoerr "GetLatestVimScripts needs fnameescape() (provided by 7.1.299 or later)"
166-
return
167-
endif
168-
169170
" Find the .../GetLatest subdirectory under the runtimepath
170171
for datadir in split(&rtp,',') + ['']
171172
if isdirectory(datadir."/GetLatest")
@@ -377,7 +378,16 @@ fun! s:GetOneScript(...)
377378
let t_ti= &t_ti
378379
let t_te= &t_te
379380
let rs = &rs
381+
let ssl = &ssl
382+
380383
set t_ti= t_te= nors
384+
" avoid issues with shellescape() on Windows
385+
if s:is_windows && &shell =~? '\<cmd\>'
386+
set noshellslash
387+
endif
388+
389+
" restore valures afterwards
390+
defer execute("let @a = rega | let &t_ti = t_ti | let &t_te = t_te | let &rs = rs | let &ssl = ssl")
381391

382392
" put current line on top-of-screen and interpret it into
383393
" a script identifier : used to obtain webpage
@@ -394,7 +404,6 @@ fun! s:GetOneScript(...)
394404
else
395405
let curline = getline(".")
396406
if curline =~ '^\s*#'
397-
let @a= rega
398407
" call Dret("GetOneScript : skipping a pure comment line")
399408
return
400409
endif
@@ -429,7 +438,6 @@ fun! s:GetOneScript(...)
429438
" plugin author protection from downloading his/her own scripts atop their latest work
430439
if scriptid == 0 || srcid == 0
431440
" When looking for :AutoInstall: lines, skip scripts that have 0 0 scriptname
432-
let @a= rega
433441
" call Dret("GetOneScript : skipping a scriptid==srcid==0 line")
434442
return
435443
endif
@@ -497,7 +505,6 @@ fun! s:GetOneScript(...)
497505
" call Decho("***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">")
498506
echomsg "***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">"
499507
" call Dret("GetOneScript : srch for /Click on the package/ failed")
500-
let @a= rega
501508
return
502509
endif
503510
" call Decho('found "Click on the package to download"')
@@ -513,7 +520,6 @@ fun! s:GetOneScript(...)
513520
let s:downerrors = s:downerrors + 1
514521
" call Decho("***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">")
515522
echomsg "***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">"
516-
let @a= rega
517523
" call Dret("GetOneScript : srch for /src_id/ failed")
518524
return
519525
endif
@@ -547,11 +553,11 @@ fun! s:GetOneScript(...)
547553
" call Decho(".downloading new <".sname.">")
548554
echomsg ".downloading new <".sname.">"
549555
if has("win32") || has("win16") || has("win95")
550-
" call Decho(".new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape(g:GetLatestVimScripts_downloadaddr.latestsrcid)."|q")
551-
new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape(g:GetLatestVimScripts_downloadaddr.latestsrcid)|q
556+
" call Decho(".new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape(g:GetLatestVimScripts_downloadaddr.latestsrcid)."|bw!")
557+
new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape(g:GetLatestVimScripts_downloadaddr.latestsrcid)|bw!
552558
else
553-
" call Decho(".exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape(g:GetLatestVimScripts_downloadaddr).latestsrcid
554-
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape(g:GetLatestVimScripts_downloadaddr).latestsrcid
559+
" call Decho(".exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape(g:GetLatestVimScripts_downloadaddr.latestsrcid)
560+
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape(g:GetLatestVimScripts_downloadaddr.latestsrcid)
555561
endif
556562

557563
" --------------------------------------------------------------------------
@@ -654,8 +660,8 @@ fun! s:GetOneScript(...)
654660
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".installdir
655661
endif
656662
if tgtdir != "plugin"
657-
" call Decho("exe silent !".g:GetLatestVimScripts_mv." plugin/".shellescape(pname)." ".tgtdir)
658-
exe "silent !".g:GetLatestVimScripts_mv." plugin/".shellescape(pname)." ".tgtdir
663+
" call Decho("exe silent !".g:GetLatestVimScripts_mv." ".shellescape("plugin/".pname)." ".tgtdir)
664+
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape("plugin/".pname)." ".tgtdir
659665
endif
660666

661667
" helptags step
@@ -680,13 +686,7 @@ fun! s:GetOneScript(...)
680686
" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."], no need to update")
681687
endif
682688

683-
" restore options
684-
let &t_ti = t_ti
685-
let &t_te = t_te
686-
let &rs = rs
687-
let @a = rega
688689
" call Dredir("BUFFER TEST (GetOneScript)","ls!")
689-
690690
" call Dret("GetOneScript")
691691
endfun
692692

src/testdir/Make_all.mak

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ NEW_TESTS = \
173173
test_gf \
174174
test_glob2regpat \
175175
test_global \
176+
test_glvs \
176177
test_gn \
177178
test_goto \
178179
test_gui \
@@ -437,6 +438,7 @@ NEW_TESTS_RES = \
437438
test_gettext_make.res \
438439
test_getvar.res \
439440
test_gf.res \
441+
test_glvs.res \
440442
test_gn.res \
441443
test_goto.res \
442444
test_gui.res \

0 commit comments

Comments
 (0)