ctrlpvim / ctrlp.vim

Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder.
ctrlpvim.github.com/ctrlp.vim
Other
5.55k stars 260 forks source link

spaces in paths breaks `globpath()` fallback #587

Closed BourgeoisBear closed 2 years ago

BourgeoisBear commented 2 years ago

Debian bullseye Vim 8.2 has patch 8.2.0995

When using the latest version, without fallbacks for g:ctrlp_user_command:

Error detected while processing function ctrlp#init[31]..<SNR>83_setlines_post[6]..ctrlp#files[3]..<SNR>83_lsCmd:
Error detected while processing function ctrlp#init[31]..<SNR>83_setlines_post[6]..ctrlp#files[8]..<SNR>83_GlobPath[13]
..<SNR>83_GlobPath[13]..<SNR>83_GlobPath[13]..<SNR>83_GlobPath:
line    4:
E484: Can't open file /home/jstewart/Pictures/2002/Dec 14
E484: Can't open file  2002
E484: Can't open file /home/jstewart/Documents/Calibre Library/Harold Abelson
E484: Can't open file  Gerald Jay Sussman

Only triggered for files/folders with spaces in the name.

NOTE: works correctly if I i change line 428 in autoload/ctrlp.vim to:

428: if !has('patch-8.2-0995')

I believe files/paths with commas in the name will also break this.

edit: corrected line number for any future participants

mattn commented 2 years ago

Do you use latest commit?

BourgeoisBear commented 2 years ago

yes edit: my current revision is fc153aabd54f9189e576c9bfb07bac09f36f2ccd

mattn commented 2 years ago

BTW, in my environment, line 432 seems not be same as your. image

BourgeoisBear commented 2 years ago

I added debugging junk above which changed the line #. It's also 428 on my side. Sorry!

mattn commented 2 years ago

I don't reproduce this on Ubuntu. Do you set options for CtrlP others?

BourgeoisBear commented 2 years ago

Debian Bullseye, x86_64, disabled all plugins, reduced vimrc to:

let g:ctrlp_use_caching       = 0
let g:ctrlp_working_path_mode = 'rw'
let g:ctrlp_root_markers      = ['.profile']
let g:ctrlp_switch_buffer     = "et"
let g:ctrlp_user_command = {
        \ 'types': {
                \ 1: ['.git', 'cd %s && git ls-files'],
                \ 2: ['.hg', 'hg --cwd %s locate -I .'],
                \ 3: ['.profile'],
        \ },
\ }
BourgeoisBear commented 2 years ago

This is run from my home directory by the way, so I believe it is using the fallback to globpath(). Same problem if I remove the 3rd type:

let g:ctrlp_user_command = {
        \ 'types': {
                \ 1: ['.git', 'cd %s && git ls-files'],
                \ 2: ['.hg', 'hg --cwd %s locate -I .'],
        \ },
\ }
mattn commented 2 years ago

Hmm, I don't get repro.

BourgeoisBear commented 2 years ago

Simplified case:

In Vim: :CtrlP :messages

Messages maintainer: Bram Moolenaar <Bram@vim.org>
Error detected while processing function ctrlp#init[31]..<SNR>18_setlines_post[6]..ctrlp#files[8]..<SNR>18_GlobPath[13]
..<SNR>18_GlobPath:
line    4:
E484: Can't open file /home/jstewart/test/Test
E484: Can't open file  Dippy Fresh
Press ENTER or type command to continue
mattn commented 2 years ago

Now I could reproduce this. It related to ,. And it seems to be original BUG.

BourgeoisBear commented 2 years ago

Last commit eliminates most of the errors, but there are a few stragglers when I :CtrlP from my home directory:

Messages maintainer: Bram Moolenaar <Bram@vim.org>
Error detected while processing function ctrlp#init[31]..<SNR>84_setlines_post[6]..ctrlp#files[3]..<SNR>84_lsCmd:
line   26:
E684: list index out of range: 1
Error detected while processing function ctrlp#init[31]..<SNR>84_setlines_post[6]..ctrlp#files[8]..<SNR>84_GlobPath[13]
..<SNR>84_GlobPath[13]..<SNR>84_GlobPath[13]..<SNR>84_GlobPath:
line    9:
E944: Reverse range in character class
E944: Reverse range in character class
Press ENTER or type command to continue
mattn commented 2 years ago

This is already fixed.