There was a fix in #1043 which improves the behavior for non saved
filenames. Those are not on disk, but also not empty. This lead to an
issue #1059 where actual "empty files" like created with vim-startify or
stdin lead to an error. This change fixes this by adapting the order of
the tests. It'll print "no file for the current buffer" for empty files.
Solves #1059
* 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.