-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Windows] Node path could have different case if the initial directory is entered in all lower case #1241
Comments
Temporary fix diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim
index b9d45dc..53fbc9a 100644
--- a/lib/nerdtree/creator.vim
+++ b/lib/nerdtree/creator.vim
@@ -76,7 +76,8 @@ endfunction
" FUNCTION: s:Creator.CreateWindowTree(dir) {{{1
function! s:Creator.CreateWindowTree(dir)
let creator = s:Creator.New()
- call creator.createWindowTree(a:dir)
+ exec 'cd '.a:dir
+ call creator.createWindowTree(getcwd())
endfunction
" FUNCTION: s:Creator.createWindowTree(dir) {{{1 |
@char101, I'm not seeing the error you describe. Putting your |
Did you open a file or directory two level under the initial directory? To demonstrate the problem you also can run I can't find any relevan vim settings that affects the glob result case. |
It seems like this behavior is affected by If I don't set If I set If I set |
So like I wrote, this is caused by |
The problem can also be fixed by not trying to make glob return relative path diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim
index f5f7682..3b1823c 100644
--- a/lib/nerdtree/tree_dir_node.vim
+++ b/lib/nerdtree/tree_dir_node.vim
@@ -273,16 +273,18 @@ function! s:TreeDirNode._glob(pattern, all)
" Construct a path specification such that globpath() will return
" relative pathnames, if possible.
- if self.path.str() ==# getcwd()
- let l:pathSpec = ','
- else
- let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',')
-
- " On Windows, the drive letter may be removed by "fnamemodify()".
- if nerdtree#runningWindows() && l:pathSpec[0] == nerdtree#slash()
- let l:pathSpec = self.path.drive . l:pathSpec
- endif
- endif
+ " if self.path.str() ==# getcwd()
+ " let l:pathSpec = ','
+ " else
+ " let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',')
+ "
+ " " On Windows, the drive letter may be removed by "fnamemodify()".
+ " if nerdtree#runningWindows() && l:pathSpec[0] == nerdtree#slash()
+ " let l:pathSpec = self.path.drive . l:pathSpec
+ " endif
+ " endif
+
+ let l:pathSpec = self.path.str({'format': 'Glob'})
let l:globList = [] |
This comparison in
|
Which version of Vim are you using? I'm on Neovim, and I don't see any of the issues you're describing. Maybe it's been fixed in Neovim. I don't want to abandon the relative paths because I believe they're needed for
diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim
index f5f7682..de117ac 100644
--- a/lib/nerdtree/tree_dir_node.vim
+++ b/lib/nerdtree/tree_dir_node.vim
@@ -273,7 +273,8 @@ function! s:TreeDirNode._glob(pattern, all)
" Construct a path specification such that globpath() will return
" relative pathnames, if possible.
- if self.path.str() ==# getcwd()
+ if self.path.str()[0] ==? getcwd()[0] && self.path.str()[1:] ==# getcwd()[1:]
let l:pathSpec = ','
else
let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') |
I am using GVim 8.2.2825. I feel that you don't get the idea of what I was trying to explain here. The problem is not with using relative path (although the relative path detection does not always work, based on whether that path ends with The idea is: If you have a directory and files in all uppercase:
And you run this in vim:
I also tried this in Now if I browse to Now what is the value of What is the value of
What is the value when the paths as combined
What is the path value of its parent node?
And now when trying to open The solution is not to abandon relative path if relative path is required. You need to normalize the initial directory case to its real case. One way is by |
I've checked this example with the latest version of NERDTree, It seems that it has been fixed after the #1387 PR. |
Self-Diagnosis
:h NERDTree
Steps to Reproduce the Issue
tab edit c:\dir
)Current Result (Include screenshots where appropriate.)
Some file and/or directory cannot be opened depending on whether the node path is stored with lower case drive name or upper case drive name.
Expected Result
File and or directory can be opened.
The Cause
c:\dir
), this results in path names starting with lower case drive name (or whatever case the user entered since path names are case insensitive on Windows)cwd
(which have been set toc:\dir
, butgetcwd()
return its properly cased nameC:\dir
), thus when joined it results in different caseC:\dir\file
This is one example if I put
call confirm('skipped '.a:path.str().' | '.self.path.str())
in tree_dir_node.vim#L125.Although
a:path
should be underself.path
, it is skipped because the drive name cases are different. NERDTree was opened by runningtabed e:\projects\pip
.The text was updated successfully, but these errors were encountered: