* If file path doesn't exist, :NERDTreeFind its parent directory instead.
This happens in the following scenario:
```
:edit path/new_file
:NERDTreeFind
```
Instead of an error message about an **invalid path**, this change will
now find the parent directory instead. It will not work if the new file
is **path/new_folder/new_file**, and that's OK because even vim itself
cannot handle both the new folder and the new file; `:w` won't create
the new folder.
* Update version number in change log.
* Change version change from PATCH to MINOR.
* add option to spawn split from previous window
* Update some comments and remove debugging statement.
* Simplify the code, and make it respect NERDTreeWinPos and 'splitbelow'.
* Better logic for getting NERDTree window number when not active window.
* Use common functions for splitting windows. Make splitting respect user.
The placement of split windows now respects the user's choices for the
splitright and splitbelow settings, and the g:NERDTreeWinPos variable.
* Update version number in change log.
* Use :edit in openExplorer to allow NERDTreeHijackNetrw to do its thing.
* Remove commented-out code.
* Make `e` work on file nodes, opening a new NERDTree or netrw buffer.
* Update change log.
* Add an optional parameter to neredtree#exec to suppress all events.
The value doesn't matter, but 1 is a good choice. Its presence is an
indicator that tells NERDTree to tell Vim to ignore all events. I'm not
yet sure if there needs to be an else section to that if block. It may
be OK to allow all events to fire in the right situations.
* Supress events in all intermediate nerdtree#exec calls.
Finding all the right function calls is the key here.
* Make ignoreAll a required parameter to nerdtree#exec().
* Put required ignoreAll argument (==0) in where it's now needed.
* Ignore events when creating a new vertical split.
* Ignore events when closing NERDTree. This may need to be reverted.
* Remove debugging statment and commented-out code.
* Wrap remaining buffer/window-switching commands in nerdtree#exec().
* Update version number.
* Add a space between arguments in nerdtree#exec() calls.
* Revert "Use :mode only in neovim. MacVim still needs to use :redraw! (#1019)"
This reverts commit 4ac07f52a3.
* If not Neovim, use `:redraw!` as was done before.
* Update version number.
* Fix punctuation in NERDTree Menu instructions.
* Use :mode only in neovim. MacVim still needs to use :redraw!
* Make nerdtree#redraw do both redraw and redraw! based on a parameter.
* Make bang a required parameter.
* Replace all redraw statments with call nerdtree#redraw function calls.
* Update version in change log.
* Define default values for new variables governing new "Default Open".
"Default Open" means to open a file with the Enter key (which of course
can be changed.) The key can be changed in the vimrc, and there is a
variable for specifying the Opener parameters for opening the node. This
lets the user decide whether Enter (or another key) will open a file in
the current tab or a new one, and whether or not to open the file again
in the tab or jump to a window where the file is already open.
* Remove the old mapping for <CR>, a duplicate of 'o'.
<CR> will be defined like all the other keys, in plugin/NERD_tree.vim
* Assign functions to the new <CR> key mapping.
Three separate functions handle directories, files, and bookmarks.
* Rename variables: NERDTreeCustomOpen and NERDTreeCustomOpenArgs
* Add documentation for NERDTreeCustomOpenArgs and NERDTree-<CR>.
* Make key mapping variables be indexed in the Vim help
* Remove angle brackets from <CR> to see if help navigation improves.
* Rename functions from defaultOpen... to customOpen...
* Use separate options for file and directory nodes.
* Update documentation for separate file/directory options.
* Update version number and change log.
* Change CR to <CR> in help tags.
* Fix missing backtick in patch number.
* Update the quickhelp text.
* Update Pull Request template.
* Update change log with simpler formatting of patch number.
* Get NERDTree version number directly from CHANGELOG.md
* Reformat the lists of contributors in the Change Log.
* Initialize the version text, just in case the while loop finds nothing.
* Fix NERDTree opening with the wrong size.
There were two commands that seemed to be causing the NERDTree window to
open in exactly half the screen width. They are:
- silent! execute 'edit ' . t:NERDTreeBufName in _createTreeWin()
- setlocal nobuflisted in _setCommonBufOptions()
These commands were reseting the width of NERDTree. The solution I chose
was to resize the window after creating the new window, and then to set
winfixwidth before setting the other common buffer options.
* Update change log and version number.
* Update CHANGELOG and change it to Markdown format.
* Add PR template with checklist for advancing the version number.
* Update version number.
* Change PR number in change log and PR template.
* Add function to preview bookmarks.
File bookmarks are previewed like regular file nodes.
Directory bookmarks are located with NERDTreeFind in the current tree.
* Update help doc to include the new bookmark preview functionality.
When :NERDTreeFind creates a tree, it resolves the file's path, and
makes that its root. See :h resolve() for more info; it basically
tracks down links to their ultimate source. Then :NERDTreeFind
tries to find the file under that root, so it can be revealed. The
problem is that it compares the file's unresolved path against the
resolved path in the root. Here is the scenario:
/tmp/ is a link to /private/tmp/
:e /tmp/foo will open the file as expected
:NERDTreeFind will first create a tree with a root of /private/tmp/
Then it tries to find /tmp/foo, but it can't, because the path
names don't match.
This commit resolves /tmp/foo to the actual location of
/private/tmp/foo; thus, it is able to find the file in the tree.
This commit refactors the "nerdtree#ui_glue#UpDir()" function to fix
a bug in the behavior of the 'u' mapping. To reproduce the bug:
1. Open a bookmarked directory with 'o'
2. Press 'u' twice, observing normal behavior
3. Open the same bookmark again with 'o'
4. Press 'u' again, observe the new root is closed
The reason for this bug is that the parent node already existed and
was closed by the second 'u' press in step two above.
This commit fixes this bug by being careful to always open the new
root and transplant the child node properly. Also, the internals of
the function in question were refactored to make use of valuable
NERDTree functions that ultimately help to reduce the amount of code
needed for this operation.
The definitions for certain bookmark mappings reference callbacks
that don't actually support operation on bookmarks. Furthermore,
the mappings that are defined are not documented anywhere. Removing
them seems reasonable since they serve no real purpose.
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.
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.
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.
Issues #597, #642, and #650 all report problems with the NERDTree
handler function for middle mouse clicks. In all cases, the problems
arose from the use of a function that didn't exist and from the use
of a bad argument in the call to the "g:NERDTreeAddKeyMap" function.
The fix for the first problem is obvious, but the solution to the
second bug merits explanation.
Previously, middle click events in the NERDTree window were
triggered with the "<MiddleRelease>" Vim key code. Since
"<MiddleMouse>" is always triggered before "<MiddleRelease>", The
error in #642 was bound to occur (because of the default behavior
for middle mouse clicks). Thus, the problem was easily solved by
using "<MiddleMouse>" instead of "<MiddleRelease>" in the mapping.
As an enhancement, I added the trigger of a "<LeftMouse>" event as
the first command in the handler function. This will cause the
middle click to reposition the cursor below the pointer before
continuing with its normal behavior. The benefits of this are clear.
This mapping has no defined behavior for bookmarks. Unless an issue
is raised to address this, it will be left just so for now.
Fixes#597, fixes#642, and fixes#650.
I altered the behavior of the ":OpenBookmark" command to match that of
the "NERDTree-o" mapping. This is acceptable for the following reasons:
1. It was broken, so no one was using it.
2. The name matches its behavior.
If a bookmark is to be opened in an explorer window, we should have a
command with a matching name for that behavior (":ExploreBookmark", for
example). This can be added later if there is enough demand for the
feature. Otherwise, this is a perfectly valid change.
Sorting the list of user bookmarks requires care to ensure that Vim's
builtin sort function is called correctly. Previously, this function was
called incorrectly. This is why the sorting of bookmarks never worked.
The offending functions have been removed here and replaced with
"s:Bookmark.CompareBookmarksByName". To understand the necessity for
this change, read ":h sort()" for the requirements of the function
reference argument (esp., note that it must return -1, 0, or 1).
In addition to fixing this problem, the new comparison function will
inspect the "g:NERDTreeBookmarksSort" setting to determine whether
case-sensitivity is preferred in the sort. The documentation has been
modified to accurately reflect this adjustment. The change is also made
in such a way as not to break any existing configurations.
Fixes#361 ("My bookmarks aren't sorted").