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.
This small change reverts to the previous method of breaking shell
output into lines. The reason for this is to avoid the printing of
trailing carriage return characters on Windows.
The (l) menu command breaks on Windows systems when 'shellslash' is
set. This is due to the fact that the menu item uses a hard coded
shell command, thus relying on the use of the default Windows shell
without the 'shellslash' setting.
The pattern used for the fix is localized to the problem function.
However, this technique could easily be abstracted into its own
function to execute Windows shell commands with the default shell
throughout the NERDTree codebase.
This check did not use the proper abstract method to check for a
path separator. It now does.
This fixes a problem with the 'u' macro that I noticed while working
on the fix for using the NERDTree with 'shellslash'.
This method used the brittle "Path._escChars()" method to do its
work. This created problems when 'shellslash' was in use on Windows
because excessive escape characters (i.e., backslashes!) are
interpreted by Vim as additional path separators.
The above problem made it impossible to edit files with weird names
using the NERDTree on Windows with 'shellslash' set. For example,
'+' should be escaped with ":edit", but '(' should not. So, when
escaping '(', Vim on Windows correctly sees the start of a new
directory in the path.
This was reported in five issues which may be read for further
details and commentary.
Fixes#398, fixes#474, fixes#653, fixes#674, and fixes#733.
Several issues (namely issue #733) report problems with using the NERDTree
on Windows when 'shellslash' is set. This commit doesn't solve all of these
problems, but it improves the NERDTree's recognition of this setting.
Especially note the improvements to the commentary on "Path.str()".
This method does too much. However, it is used heavily, and changing
its interface would be a major undertaking at this point.
This commit is the first in a series of commits that will rework
some of the methods responsible for escaping pathnames. Some of
these methods simply don't use the features that Vim has properly.
The custom "Path._escChars()" method is far too rigid for our
purposes, and better options have been available for some time.
See ":h fnameescape()" for an especially helpful function in this
effort.
The highlighting rules "NERDTreeClosable" and "NERDTreeOpenable" did
not recognize files beginning with a "~" character. This caused bad
highlighting on systems that use "~" and "+" for the dir arrow
symbols by default. Making these rules more specific solves this
problem.
The "~" characters in quickhelp section titles also would get
confused with a custom mapping for "~". Adjusting the
"NERDTreeHelpTitle" solved this problem.
I also changed the quickhelp title in a minor way to reflect the
proper spelling of "NERDTree".
The previous change to this function was simple. I figured that it
would be a good time to improve the style of this function with some
minor edits. The function is now cleaner and more readable.
Two key changes were made:
1. A screenshot was added for visual appeal.
2. The massive (and noisy) feature list was removed. This
information is adequately covered in the docs.
Fixes#573.
When bookmarks are opened normally (i.e., when a bookmark is made
the root of the current NERDTree), any open children of that
bookmark will remain open.
This is often inconvenient, especially for users who want bookmarks
to appear "fresh" when opened.
The "TreeDirNode.getDirChildren()" method is never called and can be
safely removed.
Further, note that this method has a bug. It calls the "filter()"
builtin function, which modifies "self.children" in-place. This is
obviously not a desirable side effect of calling this function.
If the functionality is genuinely required later, "filter()" should
be called on a copy of "self.children" to achieve the desired
result.
As reported in issue #67, the function driving the `p` mapping was
not updated to work as expected when the cursor is positioned on a
cascade. This problem is addressed here.
Fixes#67.
The support function for this method was unnecessary, so I took the
time to remove it. Since "TreeDirNode.openRecursively()" now calls
the "open()" method, it can take advantage of the improvements made
to that function in recent commits. Specifically, this method will
reflect the bugfix provided in pull request #720.
A proper instance method was substituted for the more brittle
equality test in the "TreeDirNode.open()" method.
Note that the order of the tests was reversed to account for the
fact that the "isRoot()" method can only be called after the first
test has passed.
This method required adjustment to take cascades into consideration.
Since the arrow in the NERDTree window reflects the status of the
tail directory of the associated cascade, an arrow indicating open
status can be present when a higher directory in the cascade was
closed.
This commit will automatically close child nodes within the same
cascade of a closed directory node so that the arrow accurately
reflects what is rendered.
Issues #547 and #526 reported a problem with the "open()" method in
the "TreeDirNode" class.
Specifically, opening a cascade in the NERDTree will perform the
opening operation on the tail of the cascade. This is a problem when
other operations (such as the "u" mapping) close intermediate
cascaded directories, which causes opening the tail to have no
effect (other than toggling the arrow).
Here, the "open()" method was modified to open all directories in a
cascade whenever the tail is opened. This is the only reasonable fix
for this type of problem.
Fixes#547 and fixes#526.