Here, a more accurate method of determining whether or not to show
hidden files is used. A new method, "isHiddenUnder()" is defined
for "Path" objects. This method is then used to set the flag for
hidden files in the ":NERDTreeFind" command. Note that this
function is likely to be useful elsewhere.
Fixes#189.
In certain cases, ":NERDTreeFind" would fail to reveal files that
were created/written after the current tab's NERDTree had been
initialized. This pull request repairs that problem.
If a file does not exist for the current buffer, this function
should fail with a clear warning message.
Here, I improved the messages that this function prints so that it
fails gracefully when no path can be determined in the calling
context.
The ":NERDTreeFind" command calls the "reveal()" method on the
NERDTree root node. The "reveal()" method would, in turn, call the
node's "open()" method. Since the "open()" method would only
initialize the child nodes of the root (i.e., read them from disk)
when the list of child nodes was empty, new paths would not be
included in the list.
This commit will result in the refreshing of the child node list
whenever "reveal()" is called on a directory node (unless it is the
first time the node is being opened... the most efficient option).
The result is that ":NERDTreeFind" will discover newly created paths
that exist on disk but are not cached in the NERDTree.
A stray debugging message is also removed.
Fixes issue #779.
Function-local variables, instead of script-local variables, should
be used here. In addition, "empty()" is a better choice for testing
for the absence of an argument. Finally, the use of "else" is
removed.
The docstring is also updated to include the new argument.
I contend that we should use confirm() whenever possible. It makes
the code cleaner and uses a builtin feature rather than a custom
one. Doing it the "Vim way" is always preferable in my mind.
The "o" mapping, which toggles directory nodes open/closed, allowed
the user to close the tree root. This was not consistent with the
"x" mapping which stops the user from doing this. This applies to
a double-click on the root node as well.
It should be noted that, if the root node is somehow closed, "o" and
double click can still re-open the tree, even with this change. In
other words, I was careful.
Previously, pressing "x" on the tree root would result in
unpredictable behavior. The user would either an receive an error
message or the parent of the tree root (which is not visible) would
be closed. This commit repairs this problem.
In addition, some code duplication was removed.
This bug is subtle! Opening a directory node in a new tab (with the
"t" or "T" mappings) would previously fail and require a refresh
because it called the directory node's "activate()" method.
In reviewing that method (i.e., "activate()"), I discovered that the
directory node's NERDTree is rendered before the method returns,
which overwrites the content of the tree in the new tab or window.
To clarify, when "t" or "T" is used on a directory node, a new
directory node and tree must be created to be rendered in a new tab.
So, calling "self.getNerdtree().render()" at the bottom of
"activate()" will render the NERDTree instance from which "t" or "T"
was invoked, not the new NERDTree that is being displayed. This
overwrites the new NERDTree text, and, thus, a refresh is required.
Since a call to "render()" is almost always necessary at the bottom
of "activate()" to keep everything in sync for other mappings, we
avoid this problem entirely by using the "open()" method directly
(works for files and directories) in the callbacks.
Fixes#549.
This change will display the file size (printed with the "ml"
command) in an easy-to-read format, while still displaying its
precise value. It uses the "stat" command (with the correct
switches for Unix and OSX) to get the file size, "sed" to add the
commas, and "sed" again to replace the original size with the
modified number.
Previously, deleting a file in the NERDTree with "md" would cause
a new buffer to be created to fill the window(s) occupied by
a buffer on the file. This pull request makes it so that a new
buffer is not created. Instead, the next buffer in the buffer list
fills the window.
Fixes#755.
Directory tree navigation is broken because of directory signs which is
shown in UTF-8.
Cygwin is a Windows application, so it uses ASCII codepages and so
directory signs must be in ASCII, but if to modify
"nerdtree#runningWindows" function there are many other functions break
that convert paths, e.g.
So, the quick and reliable solution is to add a
separate function "nerdtree#runningCygwin" and use it in a specific
place.
When g:NERDTreeChDirMode is 2, changing the tree root will change the working
directory as well. This change was silent because the wrong function was used to
make the switch. This commit uses a better function that echoes a message.