Commit Graph

228 Commits

Author SHA1 Message Date
Jason Franklin
e9d3f72d9c
Function "s:UI.getLineNum()" doesn't always work on cascades. (#882)
This PR is a rewrite of the "s:UI.getLineNum()" function.  This change
improves the logic and clarity of this function, and it fixes the function's
ability to work with cascades.

Fixes #529.
2018-09-13 08:39:09 -04:00
Phil Runninger
b3804dcd71
Merge pull request #871 from scrooloose/trap_bad_bookmark_path
Make sure the path to the bookmarks file exists before writing it.
2018-09-10 17:34:06 -04:00
Phil Runninger
129a241b22
Merge pull request #870 from scrooloose/undo_zoom_on_open
Unzoom NERDTree when opening a file
2018-09-10 06:34:05 -04:00
Phil Runninger (mac)
f78cf63627 Instead of creating the bookmark file path, show error message.
This change puts the burden on the user to make sure
g:NERDTreeBookmarksFile is correctly set and the path it contains is
present and has the proper permissions. If this is not the case, an
error message is displayed. This is a better solution than to blindly
create the path, when it may actually be impossible to do so.
2018-09-09 21:29:20 -04:00
Phil Runninger (home)
808f5b225b Escape commas in the globpath() function's path argument.
If not escaped, commas will cause globpath() to search in multiple
directories, none of which really exist.
2018-08-25 09:52:55 -04:00
Jason Franklin
b8cc044760
Merge pull request #875 from scrooloose/open_differently_cased_files
Force a case-sensitive comparison of new and existing buffers.
2018-08-25 09:36:57 -04:00
Phil Runninger (mac)
39a89f5e50 Use <count>tabnext instead of <count>gt to allow users to remap gt. 2018-08-22 09:16:33 -04:00
Phil Runninger (mac)
026bfaf35e Do a case sensitive comparison of new/existing buffers.
When NERTDtree opens a file, it compares this new file to all open
buffers to see if it's already open. If the user has 'ignorecase' turned
on then the comparison of "file" and "File" says they're the same, and
NERDTree won't reopen the file. This commit forces a case sensitive
comparison by using the ==# operator.
2018-08-15 13:22:06 +00:00
Phil Runninger (mac)
7d9a3f0e8b Make sure the path to the bookmarks file exists before writing it. 2018-08-07 18:13:40 -04:00
Phil Runninger (mac)
b6978ecd70 Unzoom only when user want NERDTree to stay open. 2018-08-07 10:01:09 -04:00
Phil Runninger (mac)
192b07ce1f If the NERDTree is zoomed when 'o'pening a file, unzoom it.
'go' does not trigger this new behavior, because focus remains in the
NERDTree.
2018-08-07 09:00:39 -04:00
Jason Franklin
456367ab07 Put cursor on root when closing bookmark table
If the cursor is not already positioned on a node when the bookmark
table is closed, then the resulting position of the cursor is not
determined.  Here, we default to positioning the cursor on the
root when the bookmark table is closed.
2018-08-02 09:17:18 -04:00
Phil Runninger (mac)
e99a7a0313 Restore the cached _sortKey for faster processing.
Also add a new global variable to track when the g:NERDTreeSortOrder
changes. If it has been changed, or when the cached _sortKey value is
uninitialized, then calculate the sort key. This improves processing
speed over the previous commit, and allows on-the-fly changes to the
sort order, (without required vim to be restarted.)
2018-07-27 08:46:50 -04:00
Phil Runninger (mac)
1e2b7ef98d Remove AddDefaultGroupToSortOrder check from startup.
The call to AddDefaultGroupToSortOrder in NERD_tree.vim is redundant
because it's also done every time sortChildren is called. And since the
check is done only once, there's no need for a function either.
sortChildren now just contains the needed if statement.
2018-07-02 09:06:09 -04:00
Phil Runninger (mac)
6ef3213cd0 Fix indentation. 2018-07-02 08:55:32 -04:00
Phil Runninger (mac)
a053925279 Recalculate the node's sortkey every time.
The cached _sortkey wasn't being recalculated after changing the
NERDTreeSortOrder, resulting in incorrect sort orders.
2018-07-01 19:57:02 -04:00
mnussbaum
eb048a3070 Bugfix - ensure keymaps dictionary exists before using it
The s:KeyMap._all function isn't necessary if we initialize the
s:keyMaps dictionary at file load time.
2018-06-12 13:46:14 -07:00
mnussbaum
657be6b24d Mark private function with leading underscore 2018-06-12 08:28:04 -07:00
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