Commit Graph

79 Commits

Author SHA1 Message Date
Jason Franklin
e48ae299f9 Update the delete bookmark map to use confirm()
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.
2017-12-01 08:45:18 -05:00
Jason Franklin
ac94cd28c2 Make the "o" mapping consistent with "x"
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.
2017-11-19 16:37:54 -05:00
Jason Franklin
e0e36c5385
Fix a problem with the "x" handler (#768)
Pressing "x" on a cascade could close the root of the tree.  This
commit prevents that from happening.
2017-11-18 10:55:43 -05:00
Jason Franklin
f526c4e652
Clean up the handler for the "x" mapping (#767)
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.
2017-11-18 09:51:34 -05:00
Jason Franklin
c9f7014034 Fix handlers for "t" and "T" on bookmarks
The "t" and "T" mappings didn't work on bookmarks.  This commit
fixes this problem by making the callbacks more general.

Fixes #565.
2017-11-11 12:10:08 -05:00
Jason Franklin
ae1c95bcbc Explicitly call open() in "ui_glue.vim" callbacks
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.
2017-11-11 11:19:16 -05:00
Alexey Shumkin
cb9f4db6ff fixed: directory navigation does not work on Cygwin
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.
2017-10-27 10:06:51 +03:00
Jason Franklin
49c165a103 Update the function that drives the p mapping
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.
2017-07-08 11:33:10 -04:00
Phil Runninger
626e80f6e4 Merge pull request #536 from satori/master
Add support for natural sorting order.
2017-06-21 11:33:47 -04:00
Jason Franklin
c934b50c0d Repair the broken middle mouse click handler
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.
2017-06-19 17:28:41 -04:00
Jason Franklin
3063dfb766 Refactor the :OpenBookmark command
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.
2017-06-10 15:59:56 -04:00
Jason Franklin
0b65089122 Reimplement the bookmark comparison method
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").
2017-05-26 13:23:05 -04:00
Phil Runninger
d99967cadd Revert "Determine if we're running in Cygwin on Windows." 2017-05-23 07:15:35 -04:00
Phil Runninger
fce10d1b10 Merge pull request #626 from scrooloose/win32unix
Determine if we're running in Cygwin on Windows.
2017-05-20 03:25:38 -04:00
Greg Hurrell
0c0bde3106 Update stale comments
@lifecrisis pointed out this stale comment here:

https://github.com/scrooloose/nerdtree/pull/578#issuecomment-302392831

Closes: #640
2017-05-18 07:02:02 -07:00
Phil Runninger
45f4d61f04 Merge pull request #578 from wincent/eventignore
Suppress autocmds less aggressively
2017-04-12 09:50:28 -04:00
Martin Grenfell
eee431dbd4 really fix the previous buffer issue when closing a tree win
So :bprev was failing to jump back to the right buffer. I dont fully
understand this yet, but I'm fairly sure this is because there is a
magic <directory> buffer that we delete when creating a wintree :-/

Anyway, we are explicitly storing the prev buffer again - and updating
it when reusing treewins. It's worky, but there may be a superior way...
2016-10-21 14:48:05 +01:00
Martin Grenfell
48df6bfd6e Revert "remove NERDTree.previousBuf() and related code"
This reverts commit 2027ae03db.
2016-10-21 14:40:18 +01:00
Martin Grenfell
2027ae03db remove NERDTree.previousBuf() and related code
We were using this when closing a wintree - to go to the previous
buffer. Not sure why we weren't just using `:bprev` ...
2016-10-19 13:28:44 +01:00
Phil Runninger
4477078170 Unlet! the nt variable before letting it.
Some will have a "NERDTree" buffer variable and others will not. In the
ones that do, getbufvar will return a dictionary. getbufvar will return
an empty string from the other buffers. When looping through the buffers,
let will throw an error if nt already exists and is a different type than
what is trying to be put into it. This easily can be illustrated by these
two statements:

:let x = ""
:let x = {}
E706: Variable type mismatch for: x

This commit gets rid of the variable before setting it so that the
mismatch cannot occur.
2016-10-17 10:30:33 -04:00
Martin Grenfell
84e7a77a7e reuse win trees when editing the same dir again
If you do

```
:edit some/dir/
```

then do the same thing at a later point, then the same nerdtree buffer
will be loaded/shown the second time.
2016-10-14 16:34:08 +01:00
Phil Runninger
a9a5aec9c0 Determine if we're running in Cygwin on Windows. 2016-10-06 17:51:22 -04:00
Łukasz Adamczak
2924ab2071 Verify we haven't reached root when traversing cascade 2016-06-22 13:59:49 +02:00
Łukasz Adamczak
c99312442b Fix upward traversal when closing a cascade 2016-06-22 13:32:44 +02:00
Greg Hurrell
35b04fa3df Suppress autocmds less aggressively
This is the counterpart to a PR I just submitted to undotree
(https://github.com/mbbill/undotree/pull/61).

I noticed that my statusline doesn't update properly when using NERDTree to move
between revisions of a file with `go` or `gi`
(https://github.com/wincent/wincent/issues/16). I established that this was
because it was using `'eventignore'` to suppress all autocmds, which in turn
prevents the statusline from updating.

Commenting out the `set eventignore=all` line makes the failure to update go
away, at the cost of firing more autocmds.

I considered adding an option for opting out of this behavior (eg. `let
g:NERDTreeEventignore=0` or something), or rearchitecting my statusline to use
an approach like vim-airline does based on CursorMoved autocmds (see
https://github.com/vim-airline/vim-airline/issues/82; see also
30f078daf5/plugin/airline.vim (L36-L50)
for current implementation), but then realized that a simpler fix is to have
NERDTree just disable only the autocmds that it uses instead of disabling all of
them.

This is probably not enough to unbreak every bit of code in the world that
depends on those autocmds, but it does at least unbreak my use case, because it
allows my `WinLeave` autocmd to run and update the statusline.
2016-05-05 09:35:16 -07:00
brook hong
e2bbedff09 Fix #520 E716: Key not present in Dictionary: setShowHidden 2016-02-02 22:31:17 +08:00
Maxim Bublis
6251ab1e63 Add support for natural sorting order. 2016-01-19 00:21:13 -08:00
Martin Grenfell
4ebbb533c3 silence bookmark errors on startup
Just disable the warning for now. The bookmark system will be replaced
with the project system soon - so no sense putting much effort into
this.

Closes #168
2015-12-02 21:17:22 +00:00
Martin Grenfell
665f326577 remove dependency on b:NERDTree from classes that dont need it
Inject it where needed.
2015-11-20 01:44:12 +00:00
Martin Grenfell
cedb40b4f5 move TreeFileNode.makeRoot() to NERDTree.changeRoot(node) 2015-11-16 13:17:59 +00:00
Martin Grenfell
d36b793656 dont use b:NERDTreeRoot internally, but leave the var there for compat
Use b:NERDTree.root instead. I will eventually remove  b:NERDTreeRoot
altogether - but this will break some other plugins so leave it for now.
2015-11-16 11:28:24 +00:00
Martin Grenfell
0b966aa23a refactor TreeDirNode.reveal slightly 2015-11-16 09:35:31 +00:00
Martin Grenfell
83d108894e move a bunch of b:NERDTree.* vars into the b:NERDTree.ui obj 2015-11-15 00:45:57 +00:00
Martin Grenfell
4d8a0c90cb move b:NERDTreePreviousBuf into NERDTree class 2015-11-14 13:10:08 +00:00
Martin Grenfell
5c20274761 move b:NERDTreeType into the NERDTree class and add some query methods 2015-11-14 12:01:55 +00:00
Martin Grenfell
848857d18b rename "primary" and "secondary" trees to "tab" and "window" trees
This is much more accurate and descriptive.
2015-11-14 11:50:01 +00:00
Martin Grenfell
4dada8c04f update version number to 5.0.0 2015-11-13 16:57:21 +00:00
Igor Tatarintsev
dc29ec2db3 Added global variables for changing default arrows
g:NERDTreeDirArrowExpandable
g:NERDTreeDirArrowCollapsable
2015-09-11 23:52:37 +06:00
Igor Tatarintsev
188bd92658 Added global variables for changing default arrows 2015-09-11 23:44:06 +06:00
toiffel
93c9726c6d Fixed case-sensitive sorting of tree nodes when 'ignorecase' option is on 2015-07-13 03:03:14 +06:00
Vincent Tsang
80e184df56 Refactor code to use getSortKey() and replace regular expression with
simple string comparison in tree_dir_node.vim
2015-05-11 11:56:08 +08:00
Vincent Tsang
57d5bd7731 Speed up sortChildren() by using sorting token
This improves the sorting functions from 12 seconds to 0.66 seconds for
~4000 objects
2015-05-09 22:47:33 +08:00
Martin Grenfell
a87b1bf3c5 Merge branch 'update_reuse_option' 2015-05-06 21:42:03 +01:00
Martin Grenfell
8b189cb263 move some rendering and cursor moving functions out of autoload 2015-05-02 15:24:59 +01:00
Martin Grenfell
b0114d202b move dumpHelp out of autoload 2015-05-02 15:05:28 +01:00
Martin Grenfell
53d2de86eb move the closeTree functions out of autoload
Remove `closeTreeIfOpen` and just make `closeTree` fail silently.
2015-05-02 15:03:54 +01:00
Martin Grenfell
0d88ce946f move isTreeOpen() out of autoload 2015-05-02 14:44:32 +01:00
Martin Grenfell
8270b6d717 move nerdtree#getTreeWinNum out of autoload 2015-05-02 14:32:21 +01:00
Martin Grenfell
973c9906f8 refactor 3 more functions out of the monolithic autoload file 2015-05-02 14:17:52 +01:00
Martin Grenfell
f8499462c5 Revert "Use different arrow characters for compatibility."
This reverts commit f6cad7e957.
2015-05-02 11:29:43 +01:00