Commit Graph

210 Commits

Author SHA1 Message Date
mnussbaum
c6d757f198 Decrease startup-time by avoiding iteration over maps
This commit makes adding, removing and finding key maps an O(1)
operation instead of O(n), where n is the number of pre-existing maps.

In my testing, averaged over 100 iterations, this reduces the time spent
initializing NERDTree at Vim startup from ~73ms to ~9.7ms. That's with
only the default included key maps.
2018-06-10 23:55:04 -07:00
Jason Franklin
57c825a169 Add code to sort mappings in quickhelp 2018-06-06 09:02:25 -04:00
Jason Franklin
80ee0897ff Add a call to ":clearjumps" to "_createTreeWin()"
Using the ":clearjumps" command wipes out the jump list for the
current window.  This means that the user can't inadvertently jump
out of the NERDTree buffer while using the NERDTree window (i.e., by
using "<C-O>").
2018-05-26 08:43:27 -04:00
Phil Runninger (mac)
c4f8a0f370 Like m-c did before, create parent directories if needed on m-m. 2018-05-16 13:09:20 -04:00
Phil Runninger (mac)
2c38519733 Make the NERDTree buffer writable when rendering it. 2018-05-06 11:34:24 -04:00
bravestarr
abf200397f
Merge branch 'master' into fix-multibyte-path 2018-04-26 21:20:33 +08:00
bravestarr
b45f2c27ea Replace strcharpart() with substitute() for backward compatibility 2018-04-26 17:13:06 +08:00
hav4ik
0972cda243 Fixed bug 'unknown function strcharpart' for older versions of Vim 2018-04-25 03:04:18 +03:00
Phil Runninger
d3a7cd20ae
Merge pull request #830 from bravestarr/fix-multibyte-path
Display a path with multi-byte characters correctly when it is truncated
2018-04-24 14:19:36 -04:00
bravestarr
6aff1b6cd3 Display a path with multi-byte characters correctly when it is truncated
When a path is rendered in the Bookmarks area or as the header line of the
tree, it is truncated if there is no enough space for it.  But if a path
contains multi-byte characters, it should be truncated by characters, not
bytes, otherwise the path may be truncated between the bytes of a
multi-byte character.  To deal with multi-byte characters, use
strdisplaywidth() instead of len() to get the number of display cells, and
use strcharpart() instead of strpart() to truncate a path.
2018-04-23 03:09:49 +08:00
Jason Franklin
164131762f Refine the internals of the "showMenu()" function 2018-04-22 10:23:16 -04:00
Jason Franklin
38d4d2288a Clean up a function comment 2018-04-22 10:21:16 -04:00
Jason Franklin
1792b6a75b Clear output when the NERDTree menu is aborted
Previously, exiting the NERDTree menu with "Ctrl-C" or "Esc" would
leave the last line of the menu visible.  We can avoid this by
redrawing the screen when the menu is aborted in this manner.
2018-04-22 10:19:13 -04:00
Kutsan Kaplan
9afa6b3828
Add new variable g:NERDTreeRemoveFileCmd 2018-03-13 15:17:10 +03:00
Phil Runninger (mac)
dc349a072a Use a better check for existence of the NERDTree buffer.
If the user wipes out or deletes (:bw or :bd) the NERDTree buffer, there
is still a tab variable that hangs onto the name of that now-missing
buffer. Checking only that variable is not enough to decide whether to
create a new NERDTree or use the existing one. Fortunately, there
already is a function with a more complete check: ExistsForTab()
2018-03-06 08:41:06 -05:00
Martin Rubli
a0f3bf3ed6 Focus previous window when closing NERDTree
Previously closing NERDTree while two windows were showing the same
buffer would focus the first window, which was not necessarily the
previously active one.

Instead of obtaining the buffer ID of the previous buffer and
mapping that to the window ID (which is a 1:n mapping) we obtain the
unique window ID and focus the right window after closing NERDTree.

win_getid() and win_gotoid() are available from VIM 7.4.1557 but the
old behavior is used as a fallback if the two functions are not
available.
2018-02-02 21:26:17 +08:00
Jason Franklin
a019486dc8 Fix unstable behavior in "NERDTreeUI.getPath()"
This commit prevents "NERDTreeUI.getPath()" from returning a "Path"
object even when no tree node was selected.  Previously, positioning
your cursor on one of the blank lines above the tree and running...

  :echo g:NERDTreeFileNode.GetSelected()

... could potentially return the path for the current working
directory (your working directory needs to be under the tree root).
This is because the constructor for "Path" objects returns a "Path"
for the current working directory when passed an empty string.  So,
we need to short circuit the "getPath()" function for lines that
cannot possibly be tree nodes.

This solves the problem for "GetSelected()" because that method uses
the "getPath()" method from the "UI" class to do its work.

Note that this bug only presented for me on *nix systems.
2018-01-06 10:31:15 -05:00
Jason Franklin
1d14961285 Remove a noise comment 2018-01-06 09:28:15 -05:00
Jason Franklin
8f052c5b47 Simplify the commentary for the "getPath()" method 2018-01-06 09:23:27 -05:00
Jason Franklin
1e93f6840a Format the commentary in "ui.vim" 2018-01-06 09:10:10 -05:00
Jason Franklin
c6a68d4b96 Improve the style in a "TreeFileNode" method
No functional changes here.
2018-01-06 09:02:10 -05:00
Jason Franklin
d745e11b42 Format the commentary in "tree_file_node.vim" 2018-01-06 08:54:28 -05:00
Jason Franklin
e6a116a9cd Improve the code style in a "Path" method
No functional changes here.  Only style improvements were made.
2018-01-06 08:41:55 -05:00
Jason Franklin
f4df038366 Refactor the "Path" constructor 2018-01-06 08:35:34 -05:00
Jason Franklin
af3ba1ef4e Revert the bugfix from pull request #785
The small change here reverts an attempted bugfix from #785.  That
change resulted in the unintended side-effect of closing other
children of the root whenever ":NERDTreeFind" was invoked.  This was
disruptive (as reported in #793), so a new method must be found to
solve the problem of ":NERDTreeFind" not opening newly created
files.

Fixes #793.
2018-01-05 08:32:03 -05:00
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