Yggdroot / LeaderF

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.
Apache License 2.0
2.14k stars 178 forks source link

leaderf cli.py crash #1094

Closed matthew-ma-sudo closed 1 month ago

matthew-ma-sudo commented 1 month ago

" search word under cursor, the pattern is treated as regex, and enter normal mode directly nnoremap a :=printf("LeaderfBufTagAll")

nnoremap r :=printf("Leaderf rg -w -e %s ", expand(""))

nnoremap e :=printf("Leaderf rg -e %s ", expand(""))

noremap v :=printf("Leaderf rg -F --current-buffer -v -e %s ", expand("")) " search word under cursor, the pattern is treated as regex, " append the result to previous search results. noremap g :=printf("Leaderf rg --append -e %s ", expand(""))

" search word under cursor literally only in current buffer noremap b :=printf("Leaderf rg -F --current-buffer -e %s ", expand(""))

" search word under cursor literally in all listed buffers noremap d :=printf("Leaderf rg -F --all-buffers -e %s ", expand(""))

" search visually selected text literally, don't quit LeaderF after accepting an entry xnoremap gf :=printf("Leaderf! rg -F --stayOpen -e %s ", leaderf#Rg#visual())

" recall last search. If the result window is closed, reopen it. nnoremap go :Leaderf rg --recall

" search word under cursor in .h and .cpp files. noremap f :=printf("Leaderf rg -e %s -g .h -g .hpp -g .cc -g .c -g .cpp" , expand("")) " the same as above noremap f :=printf("Leaderf rg -e %s -g .{h,hpp,cpp,cc,cc,S,s} ", expand(""))

noremap p :=printf("Leaderf rg -w -e %s -g *.{py,pyc} ", expand(""))

noremap w :=printf("Leaderf rg -w -e %s -g .{h,hpp,cpp,cc,c,S,s} ", expand("")) "noremap w :=printf("Leaderf rg -w -e %s -g .{h,c} ", expand(""))

noremap b :=printf("Leaderf rg -w -e %s %s", expand(""), expand("%"))

"noremap c :=printf("Leaderf rg -w -e %s -g .{cpp,cc,c} ", expand("")) noremap c :=printf("Leaderf rg -w -e %s -g .{c} ", expand(""))

"noremap h :=printf("Leaderf rg -w -e %s -g .{h,hpp} ", expand("")) noremap h :=printf("Leaderf rg -w -e %s -g .{h} ", expand(""))

noremap p :=printf("Leaderf rg -w -e %s -g *.{py,pyc} ", expand(""))

noremap i :=printf("Leaderf rg -w -e %s -g *.{i} ", expand(""))

Describe your question, feature request, or bug.

:Leaderf rg -w -e piot_state -g *.{h,hpp,cpp,cc,c,S,s}

Steps to reproduce

:Leaderf rg -w -e piot_state -g *.{h,hpp,cpp,cc,c,S,s}

Actual behaviour

 LeaderF ► Rg ► WholeLine ► /home/matthew/work1/privbox/linux ►                                                                                                                                                                                                                                                                    ◄ 0/16 ◄ Total: 16
File "/home/matthew/.vim/plugged/leaderf/autoload/leaderf/python/leaderf/cli.py", line 699, in input^@    ret = callback()^@  File "/home/matthew/.vim/plugged/leaderf/autoload/leaderf/python/leaderf/manager.py", line 70, in deco^@    return func(self, *args, **kwargs)^@  File "/home/matthew/.vim/plugged/leaderf/autoload/leaderf/python/leade
rf/manager.py", line 2941, in _workInIdle^@    raise self._read_content_exception[1]^@  File "/home/matthew/.vim/plugged/leaderf/autoload/leaderf/python/leaderf/manager.py", line 2914, in _readContent^@    for line in content:^@  File "/home/matthew/.vim/plugged/leaderf/autoload/leaderf/python/leaderf/asyncExecutor.py", line 212, in __next_
_^@    return next(self._g)^@  File "/home/matthew/.vim/plugged/leaderf/autoload/leaderf/python/leaderf/asyncExecutor.py", line 109, in read^@    raise Exception(cmd + "\n" + lfBytes2Str(err) + lfBytes2Str(err, encoding))^@Exception: rg  --no-config --no-ignore-messages --no-heading --with-filename --color never --line-number -S -w --contex
t-separator=... -M 512 -g *.{h,hpp,cpp,cc,c,S,s} -e "piot_state" ^@*.hpp: No such file or directory (os error 2)^@*.cpp: No such file or directory (os error 2)^@*.cc: No such file or directory (os error 2)^@*.c: No such file or directory (os error 2)^@*.S: No such file or directory (os error 2)^@*.s: No such file or directory (os error 2)^@
*.hpp: No such file or directory (os error 2)^@*.cpp: No such file or directory (os error 2)^@*.cc: No such file or directory (os error 2)^@*.c: No such file or directory (os error 2)^@*.S: No such file or directory (os error 2)^@*.s: No such file or directory (os error 2)

Expected behaviour

1 arch/x86/kernel/piot.c:41:} piot_state; 2 arch/x86/kernel/piot.c:84: for (i = 0; i < piot_state.gate_nr_pages; i++) 3 arch/x86/kernel/piot.c:86: piot->workspace[i] = &piot_state.gate_pages[i]; 4 arch/x86/kernel/piot.c:88: for (i = piot_state.gate_nr_pages; i < WORKSPACE_PAGES; i++) 5 arch/x86/kernel/piot.c:97: piot->offset = piot_state.gate_nr_pages PAGE_SIZE; 6 arch/x86/kernel/piot.c:125: for (i = piot_state.gate_nr_pages; i < WORKSPACE_PAGES; i++) 7 arch/x86/kernel/piot.c:264: // info->user_base = info->base + piot_state.gate_nr_pages PAGE_SIZE; 8 arch/x86/kernel/piot.c:353: piot_state.gate_nr_pages = gate_len >> PAGE_SHIFT; 9 arch/x86/kernel/piot.c:354: piot_state.gate_pages = alloc_pages(GFP_KERNEL, get_order(gate_len)); 10 arch/x86/kernel/piot.c:356: if (!piot_state.gate_pages) 11 arch/x86/kernel/piot.c:360: // u64 vaddr = page_address(piot_state.gate_pages); 12 arch/x86/kernel/piot.c:362: memcpy(page_address(piot_state.gate_pages), (void *) piot_gate, gate_len); 13 arch/x86/kernel/piot.c:374: piot_state.debugfs = debugfs_create_file("piot", S_IRUGO | S_IWUGO, NULL, NULL, &piot_fops); 14 arch/x86/kernel/piot.c:375: if (IS_ERR(piot_state.debugfs)) { 15 arch/x86/kernel/piot.c:376: ret = PTR_ERR(piot_state.debugfs); 16 arch/x86/kernel/piot.c:384: debugfs_remove(piot_state.debugfs);

matthew-ma-sudo commented 1 month ago

9CA1CA43-47D2-2FF1-7172-1E1D8F7D6A0A 9259F5FF-EC33-94D1-D0FE-531F0A161577

matthew-ma-sudo commented 1 month ago

$ vim --version VIM - Vi IMproved 9.1 (2024 Jan 02, 编译于 Aug 16 2024 16:37:36) 包含补丁: 1-678 编译者 matthew@matthew-10-62-0-103 巨型版本 带 GTK3 图形界面。 可使用(+)与不可使用(-)的功能: +acl +file_in_path +mouse_urxvt -tag_any_white +arabic +find_in_path +mouse_xterm -tcl +autocmd +float +multi_byte +termguicolors +autochdir +folding +multi_lang +terminal -autoservername -footer -mzscheme +terminfo +balloon_eval +fork() -netbeans_intg +termresponse +balloon_eval_term +gettext +num64 +textobjects +browse -hangul_input +packages +textprop ++builtin_terms +iconv +path_extra +timers +byte_offset +insert_expand -perl +title +channel +ipv6 +persistent_undo +toolbar +cindent +job +popupwin +user_commands +clientserver +jumplist +postscript +vartabs +clipboard +keymap +printer +vertsplit +cmdline_compl +lambda +profile +vim9script +cmdline_hist +langmap -python +viminfo +cmdline_info +libcall +python3 +virtualedit +comments +linebreak +quickfix +visual +conceal +lispindent +reltime +visualextra +cryptv +listcmds +rightleft +vreplace +cscope +localmap -ruby +wildignore +cursorbind -lua +scrollbind +wildmenu +cursorshape +menu +signs +windows +dialog_con_gui +mksession +smartindent +writebackup +diff +modify_fname -sodium +X11 +digraphs +mouse -sound +xattr +dnd +mouseshape +spell -xfontset -ebcdic +mouse_dec +startuptime +xim +emacs_tags -mouse_gpm +statusline -xpm +eval -mouse_jsbterm -sun_workshop +xsmp_interact +ex_extra +mouse_netterm +syntax +xterm_clipboard +extra_search +mouse_sgr +tag_binary -xterm_save -farsi -mouse_sysmouse -tag_old_static 系统 vimrc 文件: "$VIM/vimrc" 用户 vimrc 文件: "$HOME/.vimrc" 第二用户 vimrc 文件: "~/.vim/vimrc" 第三用户 vimrc 文件: "~/.config/vim/vimrc" 用户 exrc 文件: "$HOME/.exrc" 系统 gvimrc 文件: "$VIM/gvimrc" 用户 gvimrc 文件: "$HOME/.gvimrc" 第二用户 gvimrc 文件: "~/.vim/gvimrc" 第三用户 gvimrc 文件: "~/.config/vim/gvimrc" defaults 文件: "$VIMRUNTIME/defaults.vim" 系统菜单文件: "$VIMRUNTIME/menu.vim" $VIM 预设值: "/usr/local/share/vim" 编译方式: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/uuid -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 链接方式: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lselinux -L/usr/lib/python3.10/config-3.10-x86_64-linux-gnu -lpython3.10 -lcrypt -ldl -lm -lm

Yggdroot commented 1 month ago

You should use :Leaderf rg -w -e piot_state -g "*.{h,hpp,cpp,cc,c,S,s}"

matthew-ma-sudo commented 1 month ago

You should use :Leaderf rg -w -e piot_state -g "*.{h,hpp,cpp,cc,c,S,s}"

Thank you! I am trying and get this error: =printf("Leaderf rg -w -e %s -g "*.{h,hpp,cpp,cc,c,S,s}" ", expand("<cword>")) E15: 无效的表达式: ".{h,hpp,cpp,cc,c,S,s}" ", expand(""))" E116: 函数的参数无效: printf("Leaderf rg -w -e %s -g "*.{h,hpp,cpp,cc,c,S,s}" ", expand(""))

and the .vimrc leaderf configuration: noremap <Leader>w :<C-U><C-R>=printf("Leaderf rg -w -e %s -g "*.{h,hpp,cpp,cc,c,S,s}" ", expand("<cword>"))<CR>

Finally, i found configuration: noremap <Leader>w :<C-U><C-R>=printf("Leaderf rg -w -e %s -g *.h -g *.hpp -g *.cpp -g *.cc -g *.c -g *.S -g *.s} ", expand("<cword>"))<CR>. it can work!

Thank you for your apply!

Yggdroot commented 1 month ago

Actually this issue is weird for me. Leaderf rg -w -e piot_state -g *.{h,hpp,cpp,cc,c,S,s} does not throw any error on my machine. But in fact in the command line, rg -w -e piot_state -g *.{h,hpp,cpp,cc,c,S,s} will report No such file or directory (os error 2).

I am trying and get this error: =printf("Leaderf rg -w -e %s -g "*.{h,hpp,cpp,cc,c,S,s}" ", expand(""))

You should escape the double quotes, you can write as below:

:noremap <Leader>w :<C-U><C-R>=printf("Leaderf rg -w -e %s -g \"*.{h,hpp,cpp,cc,c,S,s}\" ", expand("<cword>"))<CR>

or

:noremap <Leader>w :<C-U><C-R>=printf('Leaderf rg -w -e %s -g "*.{h,hpp,cpp,cc,c,S,s}" ', expand("<cword>"))<CR>
matthew-ma-sudo commented 1 month ago

Actually this issue is weird for me.

i try and it works. Thanks!