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

LeaderfFile DIR fails to open file at correct path #257

Closed habamax closed 5 years ago

habamax commented 5 years ago
    VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 19 2018 23:02:37)
    MS-Windows 64-bit GUI version with OLE support
    Included patches: 1-610
    Compiled by appveyor@APPVYR-WIN
    Huge version with GUI.  Features included (+) or not (-):
    +acl                +cmdline_hist       +eval               +keymap             +multi_lang         +reltime            +terminal           +vreplace
    +arabic             +cmdline_info       +ex_extra           +lambda             +mzscheme/dyn       +rightleft          -termresponse       -vtp
    +autocmd            +comments           +extra_search       +langmap            +netbeans_intg      +ruby/dyn           +textobjects        +wildignore
    +autochdir          +conceal            +farsi              +libcall            +num64              +scrollbind         +textprop           +wildmenu
    +autoservername     +cryptv             +file_in_path       +linebreak          +ole                +signs              -tgetent            +windows
    +balloon_eval       +cscope             +find_in_path       +lispindent         +packages           +smartindent        +timers             +writebackup
    -balloon_eval_term  +cursorbind         +float              +listcmds           +path_extra         +startuptime        +title              -xfontset
    +browse             +cursorshape        +folding            +localmap           +perl/dyn           +statusline         +toolbar            -xim
    ++builtin_terms     +dialog_con_gui     -footer             +lua/dyn            +persistent_undo    -sun_workshop       +user_commands      +xpm_w32
    +byte_offset        +diff               +gettext/dyn        +menu               -postscript         +syntax             +vartabs            -xterm_save
    +channel            +digraphs           -hangul_input       +mksession          +printer            +tag_binary         +vertsplit          
    +cindent            +directx            +iconv/dyn          +modify_fname       +profile            +tag_old_static     +virtualedit        
    +clientserver       -dnd                +insert_expand      +mouse              +python/dyn         -tag_any_white      +visual             
    +clipboard          -ebcdic             +job                +mouseshape         +python3/dyn        +tcl/dyn            +visualextra        
    +cmdline_compl      +emacs_tags         +jumplist           +multi_byte_ime/dyn +quickfix           -termguicolors      +viminfo            
    system vimrc file: "$VIM\vimrc"
        user vimrc file: "$HOME\_vimrc"
    2nd user vimrc file: "$HOME\vimfiles\vimrc"
    3rd user vimrc file: "$VIM\_vimrc"
        user exrc file: "$HOME\_exrc"
    2nd user exrc file: "$VIM\_exrc"
    system gvimrc file: "$VIM\gvimrc"
        user gvimrc file: "$HOME\_gvimrc"
    2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
    3rd user gvimrc file: "$VIM\_gvimrc"
        defaults file: "$VIMRUNTIME\defaults.vim"
        system menu file: "$VIMRUNTIME\menu.vim"
    Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_NETBEANS_INTG -DFEAT_JOB_CHANNEL   -DFEAT_XPM_W32   -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_MBYTE -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl86t.dll\" -DDYNAMIC_TCL_VER=\"8.6\" -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua53.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python37.dll\" -DFEAT_MZSCHEME -I "C:\Program Files\Racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_a36fs8.dll\" -DDYNAMIC_MZGC_DLL=\"libracket3m_a36fs8.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl528.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\"x64-msvcrt-ruby240.dll\" -DFEAT_HUGE /Fd.\ObjGXOULYHTRZAMD64/ /Zi
    Linking: link  /nologo /subsystem:windows,5.02 /opt:ref /LTCG:STATUS /HIGHENTROPYVA:NO oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64 gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib netapi32.lib  /machine:AMD64  libcmt.lib oleaut32.lib user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python37.lib   "C:\Tcl\lib\tclstub86.lib" WSock32.lib xpm\x64\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug

:echo g:Lf_Debug_Cmd

Describe your question, feature request, or bug.

When you have

" Convenient to :save or :write a copy of a file to the same directory.
autocmd BufEnter * silent! lcd %:p:h

then second :LeaderfFile DIR fails to open correct file.

The same happens if you have vim-rooter plugin installed.

Steps to reproduce

with autocmd:

  1. Add autocmd to your vimrc or install vim-rooter plugin.
  2. Open file in first directory with :LeaderfFile DIR1
  3. Open file in second directory with :leaderfFile DIR2

vim-leaderf-and-lcd-auto

with vim-rooter:

The same as with autocmd but DIR1 and DIR2 should be under git -- so vim-rooter will change cwd.

vim-leaderf-and-rooter

Actual behaviour

Empty file with the chosen file name is opened at incorrect path.

Expected behaviour

Choosen file should be opened.

Yggdroot commented 5 years ago

autocmd BufEnter * silent! lcd %:p:h

This command is evil, please do not use it.

habamax commented 5 years ago

I know, I don't use it. The main issue is with vim-rooter which essentially does (I think :) ) the same under the hood -- changes working directory whenever you open a file.

And because I use windows and gvim -- my workflow is mostly out of cmd line -- so my starting working directory is almost always the path vim is installed in. That is very inconvenient, and to make life easier you might start using autochdir, autocmd with lcd or vim-rooter.

PS I have tried the same with CtrlP and fzf -- they don't have that problem. But even with this annoying issue, your plugin is more convenient to me

Yggdroot commented 5 years ago

I think you should change your workflow. I also work on Windows sometimes, I have never encountered this issue. So I don't need vim-rooter. My workflow is:

  1. right click, a menu is popped up. menu
  2. select Vim Here
  3. enter vim, and the current working directory is the current directory.

How to add the Vim Here to right-click menu?

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\Shell\edit with vim8.0]
@="Edit with vim8.0"
"Icon"="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\*\Shell\edit with vim8.0\command]
@="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Shell\edit with vim8.0]
@="Edit with vim8.0"
"Icon"="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\Directory\Shell\edit with vim8.0\command]
@="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\Vim8.0 Here]
@="Vim8.0 Here"
"Icon"="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\Vim8.0 Here\command]
@="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\Drive\Shell\edit with vim8.0]
@="Edit with vim8.0"
"Icon"="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\""

[HKEY_CLASSES_ROOT\Drive\Shell\edit with vim8.0\command]
@="\"C:\\Program Files\\Vim\\vim80\\gvim.exe\" %1"

Save the text above in a file named, for example, vim.reg. Run this file. (Of course you can customize C:\\Program Files\\Vim\\vim80\\gvim.exe)

habamax commented 5 years ago

I have "Vim here", but it really is inconvenient for me.

I usually <Win>gvim<Enter> and then open files/projects needed.

Well, okay. I can see a couple ways to workaround my problem:

  1. try to ~fix it~ change the way it works in a fork of your plugin
  2. return to fzf -- try to add some parts of leaderf there (mostly your awesome LeaderfHelp)
  3. or return to CtrlP

Anyway, thanks!

Yggdroot commented 5 years ago

Fixed in dev branch, please have a try.

habamax commented 5 years ago

YES!

It is fixed! Thank you very much, really appreciated!