refactor(zip)!: address entries with zip:// paths

Problem:
`zipfile://{archive}::{entry}` is ambiguous: `::` is legal in both an
archive path and an entry path, so the separator cannot be identified.
Splitting at the last `::` reads archives correctly but breaks entries
that contain it, and the plugin then emits buffer names it cannot read
back.

Solution:
Address entries as `zip://{archive}/{entry}`, joining the two paths.
Resolve the split by walking components: the first one that is a regular
file is the archive, because a regular file cannot have children on disk.
Entry paths may then contain any character, and no escaping is needed.

zipPlugin.vim keeps its own scheme, so the Java ftplugin emits whichever
form matches the active plugin until the legacy package is removed.
This commit is contained in:
Barrett Ruth
2026-07-31 23:52:07 -05:00
parent 8787b8b9b6
commit 886a270e7f
5 changed files with 47 additions and 35 deletions

View File

@@ -80,8 +80,11 @@ if exists("g:ftplugin_java_source_path") &&
function! JavaFileTypeZipFile() abort
let l:member = substitute(v:fname, '\.', '/', 'g') . '.java'
return 'zipfile://' . get(s:zip_files, bufnr('%'), s:zip_files[0]) .
\ '::' . l:member
let l:archive = get(s:zip_files, bufnr('%'), s:zip_files[0])
" The builtin plugin joins the paths; zipPlugin.vim separates them with "::".
return exists('#nvim.zip')
\ ? 'zip://' . l:archive . '/' . l:member
\ : 'zipfile://' . l:archive . '::' . l:member
endfunction
" E120 for "inex=s:JavaFileTypeZipFile()" before v8.2.3900.
@@ -391,7 +394,11 @@ if exists("s:zip_func_upgradable")
def! s:JavaFileTypeZipFile(): string
const member: string = substitute(v:fname, '\.', '/', 'g') .. '.java'
return 'zipfile://' .. get(zip_files, bufnr('%'), zip_files[0]) .. '::' .. member
const archive: string = get(zip_files, bufnr('%'), zip_files[0])
# The builtin plugin joins the paths; zipPlugin.vim separates them with "::".
return exists('#nvim.zip')
? 'zip://' .. archive .. '/' .. member
: 'zipfile://' .. archive .. '::' .. member
enddef
setlocal includeexpr=s:JavaFileTypeZipFile()