Commit Graph

1162 Commits

Author SHA1 Message Date
Jason Franklin
8cd17c1a47 Merge pull request #731 from lifecrisis/tilde
Address special cases for three highlighting rules.
2017-07-29 09:48:16 -04:00
Jason Franklin
d68c9abca8 Improve three highlighting rules
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".
2017-07-29 09:40:11 -04:00
Jason Franklin
5af263c2df Merge pull request #729 from ParkerKemp/master
Change windows using window number when opening in new vertical
split.
2017-07-29 09:04:44 -04:00
Jason Franklin
35724ee206 Refactor the internals of "_newVSplit()"
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.
2017-07-29 08:55:28 -04:00
Jason Franklin
719d6785d4 Edit the commentary in "opener.vim"
This commit doesn't change the content of any comments. It just
changes their appearance (leading quotes are now followed by
a space).
2017-07-29 08:37:25 -04:00
Jason Franklin
1269c070cd Divide the introductory paragraph in the README
This paragraph was too long and needed to be broken.
2017-07-28 20:56:19 -04:00
Jason Franklin
7027fd156e Merge pull request #730 from lifecrisis/issue573
Improve the appeal of the "README.markdown" file.
2017-07-28 20:42:14 -04:00
Jason Franklin
6efef8651e Edit the README file
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.
2017-07-28 20:38:26 -04:00
Parker Kemp
eae5d02fa9 Use window number when opening in new vsplit 2017-07-24 15:32:59 -04:00
Jason Franklin
e2a9929bbe Merge pull request #722 from lifecrisis/open-bookmark
Have bookmarked directories open with all children closed.
2017-07-17 08:13:12 -04:00
Jason Franklin
5daec4c7b7 Edit stale commentary and add proper sigils 2017-07-14 18:02:02 -04:00
Jason Franklin
3a7694aa55 Add a call to close the children of bookmarks
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.
2017-07-14 17:52:00 -04:00
Jason Franklin
1f089a362b Rework the "TreeDirNode.closeChildren()" method
This function needed polishing; in the choice of variable names and
in the leading comment.
2017-07-14 17:36:09 -04:00
Jason Franklin
3245007f0e Remove a method from the TreeDirNode class
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.
2017-07-14 17:17:25 -04:00
Jason Franklin
a3fdf1e3c1 Merge pull request #721 from lifecrisis/issue67
UPDATE: The `p` mapping now works on cascades.
2017-07-08 11:43:38 -04: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
Jason Franklin
ab0a3a7c24 Merge pull request #720 from lifecrisis/issue526
BUGFIX: Repair opening and closing of cascades.
2017-07-08 10:04:08 -04:00
Jason Franklin
c1b71dcfc5 Rename the help file to "NERDTree.txt"
I thought renaming this file was important so that the NERDTree name
is printed with consistency. Branding is important.
2017-07-04 10:14:35 -04:00
Jason Franklin
ef35ee8918 Remove the helper function for "openRecursively()"
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.
2017-07-04 09:45:06 -04:00
Jason Franklin
7f4a7205dc Replace an equality test with an instance method
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.
2017-07-02 15:16:49 -04:00
Jason Franklin
ebc206e58d Refactor "TreeDirNode.close()" method
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.
2017-07-02 12:25:15 -04:00
Jason Franklin
8660541333 Fix the "TreeDirNode.open()" method
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.
2017-07-02 12:25:15 -04:00
Jason Franklin
18f04e0824 Refactor the "TreeDirNode.displayString()" method
I found this method to be unreadable and cumbersome. Cleaning it up
helped me to understand the design ideas behind it.
2017-07-02 12:25:15 -04:00
Jason Franklin
2e43ad074b Merge pull request #719 from lifecrisis/issue718
This pull request fixes the bug reported in issue #718.
2017-06-30 10:21:21 -04:00
Jason Franklin
2b2b35ceda Fix an inaccurate version check
Calling the function "globpath()" is complex when one is trying to
support multiple versions of Vim because this particular function
developed rapidly (as did "glob()") during the life of Vim 7.0.

This commit makes the version check for calling "globpath()" much
clearer. It also allows for rendering dead links in the NERDTree by
changing the "globpath()" call for versions of Vim that include
patch 7.4.654. This can be done later when the effects are known and
the feature is officially requested.

Fixes #718.
2017-06-30 10:11:06 -04:00
Jason Franklin
7ed79c00c1 Merge pull request #717 from scrooloose/dev
Define the "TreeDirNode._glob()" method.
2017-06-28 19:05:19 -04:00
Jason Franklin
779e13374a Edit the filter in the TreeDirNode glob method
A better style for executing the removal of each filtered name was
chosen. This is a minor change, but I viewed it as necessary.
2017-06-28 16:56:03 -04:00
Jason Franklin
2a97fb0fda Reformat the commentary in the TreeDirNode script
The commentary in "tree_dir_node.vim" needed to be cleaned up a
little. Spaces after leading quotes are a good idea, to avoid the
"clustered" appearance that comments can sometimes have.

Use the following substitution command...

  :s/^"\ze\S/" /

to make this change to longer scripts.
2017-06-28 16:55:54 -04:00
Jason Franklin
b877fc65d8 Rename and expand the TreeDirNode glob method
Pull request #710 also brought to my attention some glaring code
duplication in the TreeDirNode class. This commit renames and
expands the glob method defined in PR #710 into a more general
purpose helper method.

The new method also ensures that 'wildignore' rules are applied
consistently. Issue #569 noted that the application of the
'wildignore' setting in populating a node's children was
unpredictable. When a node was rendered, "_initChildren()" would
load the children with its own call to "globpath()". Refreshing the
same node would then invoke "globpath()" again, but with different
arguments.

The result was that a node's children were initialized using the
'g:NERDTreeRespectWildIgnore' setting, but refreshing ignored this
setting. So, if it the setting was 0, "test.class" might render when
the parent was initialized, and then be removed on refresh (if
'wildignore' contained '*.class').

This commit solves this problem by ensuring that the NERDTree
setting mentioned above is only checked and applied to a node's
children in one place by cleaning up the duplication.

Fixes #569.
2017-06-28 16:55:43 -04:00
Jason Franklin
b0c44c7be1 Refactor the TreeDirNode glob method
Pull request #710 correctly noted that TreeDirNode directories must
be passed to "globpath()" as relative paths (i.e., to the working
directory) if 'wildignore' rules for relative paths are to be
obeyed.

The solution was to use "fnamemodify()" to get a relative path to
the TreeDirNode object's directory, if possible. However, this
method does not modify our TreeDirNode path if it IS the current
working directory. Thus, immediate children of the node are seen as
absolute paths in glob results when our PWD is pointing to their
parent. This is not consistent behavior.

This commit defines the result of this function as ',' when this
special case arises to fix this problem.

See ":h 'path'" for an explanation of how this works.
2017-06-28 16:55:24 -04:00
Jason Franklin
4a487474c4 Modify call to sort() for older versions of Vim (#714)
Older Vim versions seem to require that calls to sort() specify a
dictionary when the compare function argument is a dictionary
function. This seems to be required even when the dictionary is not
used. Since this change does not seem to affect behavior in later
Vim editions, I see no harm in including it.
2017-06-22 17:15:51 -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
Phil Runninger
54b423e0f8 Merge pull request #711 from lifecrisis/issue650
BUGFIX: Broken middle click listener repaired.
2017-06-19 23:49:38 -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
Phil Runninger
5ce9bda392 Merge pull request #710 from jason0x43/globPath-fix
Handle non-relative globDir properly in Windows
2017-06-19 08:13:35 -04:00
Jason Cheatham
1d83e4c1ce Handle non-relative globDir properly in Windows
In Windows, fnamemodify with ':.' will strip the drive letter from a
path that isn't under CWD. This update ensures such a path has the drive
letter.

references #709
2017-06-18 21:23:17 -04:00
Phil Runninger (mac)
5f3a44d066 Document the :NERDTreeFocus command. Closes #706. 2017-06-16 08:50:21 -04:00
Phil Runninger
2c3249de68 Merge pull request #675 from jason0x43/relative-paths
Use relative path with globpath
2017-06-13 09:54:42 -04:00
Phil Runninger
17713ee293 Merge pull request #704 from lifecrisis/bookmarks-markers
FEATURE: The g:NERDTreeMarkBookmarks setting
2017-06-11 23:56:34 -04:00
Phil Runninger
9bd34f9424 Merge pull request #703 from lifecrisis/issue677
BUGFIX: Repair the broken ":OpenBookmark" command
2017-06-11 23:25:09 -04:00
Jason Franklin
9b3487db64 Update the option summary
It came to my attention that the option summary has been neglected for
the past few commits. I added the new option in this feature branch and
updated the descriptions of two nearby options.

This section could use some focused editing.
2017-06-11 09:47:50 -04:00
Jason Franklin
471a03c9d9 Implement the g:NERDTreeMarkBookmarks setting
The setting is self-explanatory. See the added documentation for further
details.
2017-06-10 17:07:57 -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
a03a639390 Refactor and re-document Bookmark.getNode()
A few minor changes were made to the "Bookmark.getNode()" function for
the purposes of improving readability and documentation clarity.

This process also led me to the conclusion that the "findNode()"
function should be refactored to throw an error if a node cannot be
found. This would lead to greater uniformity in the reporting of
failures to find a node. It is generally better style to have an error
thrown as close to the source as possible. A substantial change like
this should wait for now.
2017-06-10 13:29:27 -04:00
Jason Franklin
c0b90811b0 Add an argument sigil in a Bookmark class method
A missing argument sigil is effectively a syntax error in VimL. The
function in which the error occurred was called in the execution of at
least three buffer-local NERDTree commands:

 1. :Bookmark (specifically, when trying to overwrite a Bookmark)
 2. :OpenBookmark
 3. :RevealBookmark

Only one specific type of error message associated with these commands
is fixed here (see issue #677).

The problems with the above commands are not fully addressed by this
commit, and their behavior can be improved immensely by further
refactoring. However, no one has been able to even use these commands at
all before now because the fix given here was not in place.

More work will need to be done to improve the behavior of these commands
so that they truly function as any reasonable user would expect.

Fixes #677.
2017-06-10 11:18:14 -04:00
Jason Franklin
b0f60552ea Rewrite and expand the header in bookmark.vim
The header in "bookmark.vim" was pretty weak. It provided no description
of the class it contains and no direction for the reader. In particular
it did not note the dual purpose of the "Bookmark" class.

The fact that the "Bookmark" class serves two purposes must be noted
because many readers will expect class definitions to obey the single
responsibility principle!

If there is a chance for a major refactor of this class in the future, a
priority would be splitting the class in two so that a "BookmarkList"
class can assume the responsibility for providing a container for all
"Bookmark" objects.
2017-06-10 09:57:18 -04:00
Jason Franklin
81a42acb97 Refactor the bookmark query function
The function in "bookmark.vim" that allows the caller to query the list
of Bookmarks by name had stale commentary. In addition, the internals of
the function needed to be reworked to improve readability. Making this
function very clean is important because it is heavily used elsewhere.

As a side note, it might be beneficial to later rename this function to
something like "GetBookmarkByName" to further improve readability. That
change is not critical and can be safely delayed.
2017-06-10 09:28:14 -04:00
Phil Runninger (mac)
a9ab90198b Update CHANGELOG, giving contributors their due. 2017-06-05 09:00:31 -04:00
Phil Runninger
84c681989d Merge pull request #699 from asnr/add-keymaps-to-docs
Update docs with already existing mapping variables
2017-06-04 08:43:13 -04:00
asnr
3a7293d450 Update docs with already existing mapping variables 2017-06-04 19:11:46 +10:00