Commit Graph

185 Commits

Author SHA1 Message Date
Jason Franklin
d90b2af474 Add a space to help the parser 2017-12-22 10:46:49 -05:00
Jason Franklin
0ff697eb40 Implement the "isHiddenUnder()" method for Path 2017-12-22 10:28:31 -05:00
Jason Franklin
344119439e Refresh children of directory nodes on "reveal()"
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.
2017-12-21 10:36:16 -05:00
Jason Franklin
9f985514f0 Add modelines 2017-12-17 08:43:43 -05:00
Jason Franklin
c20ac9c27f
Merge pull request #772 from skyblueee/stripMarkup_leadingSpaces
Remove useless argument in user interface function.
2017-12-09 11:33:54 -05:00
SkyBlueEE
ea01a691a2 remove useless removeLeadingSpaces in _stripMarkup 2017-11-28 00:04:03 +08:00
SkyBlueEE
3485b2a939 remove useless substitute when 'file =~# "/$"' 2017-11-27 23:56:41 +08:00
Jason Franklin
70c8cb9bfa
Revert change to tab opening method (#766)
Previously the "t" and "T" mappings were altered to open new tabs at
the end of the tab line.  This commit reverts that change.
2017-11-18 09:50:40 -05:00
Jason Franklin
93356cd92b
Add back support for "b:NERDTreeRoot" (#765) 2017-11-14 18:36:09 -05:00
Jason Franklin
21c470c316 Have new tabs open as the last tab (with '$') 2017-11-14 08:29:40 -05:00
Jason Franklin
4c409a1640 Add a note/warning to "TreeDirNode.activate()"
This warning makes developers aware of the possibility of
overwriting the NERDTree text in a new window when activate is used.
2017-11-11 13:23:51 -05:00
Jason Franklin
e27cd86a9b Document "t" and "T" mappings in the quick help 2017-11-11 13:09:42 -05:00
Jason Franklin
31dbf1c139 Silence messages when opening a file with "T" 2017-11-11 12:37:04 -05:00
Jason Franklin
0a0374b826 Remove an unnecessary assignment 2017-11-11 09:09:19 -05:00
Jason Franklin
870bedef21 Clean up the Creator.createTabTree() function 2017-11-11 09:08:24 -05:00
Jason Franklin
d9074c2753 Clean up the commentary in "creator.vim" 2017-11-11 08:53:47 -05:00
Jason Franklin
3cb90cb18d Extract a common line to the top of a function 2017-11-11 08:45:34 -05:00
Jason Franklin
26168324fc Remove an unnecessary "else" clause 2017-11-11 08:34:29 -05:00
Jason Franklin
f0a97209f1 Clean up the NERDTreeOpener constructor
This method needed some love.  The internals were simplified and
reformatted, and the comment was edited for additional readability.
2017-11-11 08:29:09 -05:00
riyu ken
8a6ae7c633 Use a better function to change directories
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.
2017-09-28 09:04:01 -04:00
Jason Franklin
d7cf9a2a98 Fix the drive check in "TreeDirNode._glob()"
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'.
2017-08-11 10:14:05 -04:00
Jason Franklin
a32a55e8d9 Rewrite the "Path._strForEdit()" method
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.
2017-08-11 10:09:18 -04:00
Jason Franklin
7a2fc6b6b9 Refactor the "Path._str()" method
This method was using hardcoded values rather than provided
abstractions to do its work. These improvements were necessary.
2017-08-11 09:43:57 -04:00
Jason Franklin
19b8dd7b60 Add a check for 'shellslash' in "Path.Slash()'
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.
2017-08-11 09:32:01 -04:00
Jason Franklin
72f9135d19 Clean up the commentary for two Path methods
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.
2017-08-11 09:19:36 -04:00
Jason Franklin
b5e54d255e Rewrite the "Path._strForCd()" method
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.
2017-08-11 08:46:41 -04:00
Jason Franklin
1a121337dd Clean up the script header in "path.vim"
Some code was reorganized and comments were written/rewritten.
2017-08-11 08:33:51 -04:00
Jason Franklin
a7d667b81b Add spaces after comment leaders in "path.vim"
Here, I applied the usual fix for the cramped comments I've found in
our scripts. Use this command...

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

to fix this problem elsewhere.
2017-08-11 08:07:23 -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
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
Parker Kemp
eae5d02fa9 Use window number when opening in new vsplit 2017-07-24 15:32:59 -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
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
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
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
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
2c3249de68 Merge pull request #675 from jason0x43/relative-paths
Use relative path with globpath
2017-06-13 09:54:42 -04:00