Commit Graph

1124 Commits

Author SHA1 Message Date
Phil Runninger (mac)
64c3a6aed3 Change the containedin to ALL to conceal delmiter after filename. 2018-11-12 11:17:20 -05:00
Phil Runninger (mac)
8d005db94f Use substitute() for backward compatibility. Change conceallevel to 3. 2018-10-31 08:45:43 -04:00
Phil Runninger
91e0f2253f
Support unusual characters in file and directory names (#868)
* Use a delimiter in node to separate file/dir name from the rest.

* Switch warning message to use nerdtree#deprecated function.

* Compress the space between the tree symbols and the node.

* Include the delimiter when calculating indent or getting filename.

* Don't need to strip leading delimiter. It will already be gone.

* Simplify the way the delimiter is being used.

I don't know what I was thinking. The delimiter doesn't need to be used
to separate every indicator on the node's text, ie.

Bad:    Tree|GenericFlags|Filename|ExecutableFlag|Link|ReadonlyFlag
Better: Tree GenericFlags|Filename|ExecutableFlag Link ReadonlyFlag

This was unnecessary, given that we're only interested in the filename.
So, just one pair of delimiters is all we need. That greatly simplifies
the _stripMarkup function, and restores a bunch of other statements to
what they already are in the master branch.

* Add syntax highlighting to conceal the delimiter

* Put a if has("conceal") check around the syntax statement using it.

* Make concealment work correctly for LinkFile and readonly files.

* Use highlight Ignore if conceal isn't available.

This is probably the best we can do, especially if some other character
must be used in place of nbsp.

* Make the regex better match the original, but more compact.

It was allowing 2+ spaces, instead of only 1+.

* Fix the syntax highlighing of delimiters around NERDTreeExecFile.

* Bug fix: Parse . and .. from path string with trailing slash.

* Fix unresponsive cascaded directories.

Using ':' as a more visible delimiter, when directories are cascaded,
the line appears in NERDTree like so:

▾ :lib/::nerdtree/:

Before this commit, the s:UI._stripMarkup function was leaving the
internal delimiters in place (lib/::nerdtree/). Now they are removed,
resulting in a valid path (lib/nerdtree/).

* Use .= to shorten statement. Use clearer substitutes to get node name.

* Remove node delimiters that terminate the line.

* If flags are needed after the node name, then put another delimiter
before them.
* When joining directory nodes for cascaded display, strip off the
delimiter from the child node(s).
* Remove the unnecessary substitution of doubled intermediate
delimiters, since they're not in there anymore.

* DRY up the addition of the 2nd delimiter, and use only 1 for all tags.
2018-10-24 22:41:13 -04:00
Phil Runninger
c372911c4a
Refresh buffers after m, m operation on a folder (#888)
* WIP: Wow! That's an ugly diff. I'm not done yet, though.

* Fix the ugliness of the previous commit, and finish the work.

If the node being renamed is a directory, get a list of all open buffers
whose file lives in the old directory. If that list is not empty, ask
the user if he wants to replace the old buffers with the new files. The
logic to handle renaming a file node stays the same, although the code
has been refactored a bit.
2018-10-24 22:20:59 -04:00
Phil Runninger
388623e702
Support sorting files and directories by modification time. (#901)
* Introduce a flag to to sort by the node's modification time.

This flag is part of the NERDTreeSortOrder list. '[[timestamp]]' sorts
oldest to newest, while '[[-timestamp]]' sorts newest to oldest. Its
position in the array determines whether it is the primary sort (first
position) or secondary sort (any other position). The remaining elements
in the array describe the other sort level following all prior rules. If
needed, a tertiary sort is done alphabetically on the filename.

Examples:

['[[timestamp]]']            - oldest to newest
['\/$','*','[[-timestamp]]'] - dirs, then files, each newest first.

When using this flag, performance is slowed a little because the sortKey
is always recalculated with every sort. Why? Because if a file is saved
(either in vim or by an outside program), NERDTree needs to go back out
to the shell to get the new modification time.

* Update NERDTreeSortOrder documentation.

The new `[[timestamp]]' and '[[-timestamp]]' flags are added to support
sorting by modification time.

* Fix the inequality. Must be >= to force recalculation of _sortKey.

* Move `let path=` closer to where it's used.
2018-10-24 22:18:18 -04:00
Phil Runninger
92a20c0736
Bug fix: Parse . and .. from path string with trailing slash. (#899) 2018-10-24 22:14:18 -04:00
Phil Runninger
52151fb307
Call Resolve on the file's path when calling :NERDTreeFind. (#896)
When :NERDTreeFind creates a tree, it resolves the file's path, and
makes that its root. See :h resolve() for more info; it basically
tracks down links to their ultimate source. Then :NERDTreeFind
tries to find the file under that root, so it can be revealed. The
problem is that it compares the file's unresolved path against the
resolved path in the root. Here is the scenario:

/tmp/ is a link to /private/tmp/
:e /tmp/foo will open the file as expected
:NERDTreeFind will first create a tree with a root of /private/tmp/
Then it tries to find /tmp/foo, but it can't, because the path
names don't match.

This commit resolves /tmp/foo to the actual location of
/private/tmp/foo; thus, it is able to find the file in the tree.
2018-10-24 22:13:42 -04:00
Phil Runninger
f98078d3ae
Force sort to recalculate the cached sortKey. (#898)
* Force sort to recalculate the cached sortKey.

The problem in issue #880 was caused by the sort using the old sortKey.
For example, given nodes A, B, and C, if B were renamed to D, the sort
was still using B as its sortKey, thus not moving it.

It's a bit of a hack, but if we set g:NERDTreeOldSortOrder to an empty
list, the cached sortKey will be recalculated. I did the same thing for
both the Copy and Add functions as well.

* Add a comment to explain the let ... = [] statement.
2018-10-18 16:13:15 -04:00
Phil Runninger
820955e773
Catch all errors, not just NERDTree errors. (#894)
When middle-clicking, the s:TreeFileNode.GetSelected() function is
called along the way. If this is done outside of the NERDTree window,
there is not "b:NERDTree" variable, and the "E121: Undefined variable"
exception is thrown. This function was trying to catch only the NERDTree
specific errors; thus, it let the Undefined variable exception slip by.
This commit causes the function to catch all errors.
2018-10-18 11:35:00 -04:00
Werner Hofstra
5381197747 Add NERDTreeRefreshRoot command (#897)
* Add NERDTreeRefreshRoot command

* Document NERDTreeRefreshRoot
2018-10-16 11:08:23 -04:00
Phil Runninger
6b6cadf86c
Use a better arg for FINDSTR when using the m,l command in Windows. (#887)
* Use a better arg for FINDSTR when using the m,l command in Windows.

* Remove trailing spaces.

* Use vim getf...() functions in place of DOS commands.

* Remove unnecessary variable.

* Put labels in the text of the file/dir listing.
2018-10-10 22:19:18 -04:00
Phil Runninger
729e8014b9
Merge pull request #892 from lvoisin/work
Fix typo in help file
2018-10-08 09:06:20 -04:00
Laurent Voisin
bba4b0087b Fix typo in help file
Remove duplicated word.
2018-10-08 13:17:33 +02:00
Jason Franklin
599238ad99
Make NERDTreeCreator set the 'nolist' option (#889) 2018-09-17 08:13:07 -04:00
Jason Franklin
cd1f2c803e Fix the <C-J>, <C-K>, J, and K default mappings (#886)
These mappings currently fail on cascades.  This pull request fixes
this problem.
2018-09-15 10:20:13 -04:00
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
15d06b676d
Merge pull request #878 from scrooloose/autochdir_interference
NERDTreeCWD: reset CWD if changed by NERDTreeFocus
2018-09-10 09:27:52 -04:00
Jason Franklin
2cd4331b78 Check for unknown current working directory 2018-09-10 09:00:05 -04:00
Jason Franklin
5442d5e04a Put cursor in first column 2018-09-10 08:52:43 -04:00
Jason Franklin
7e00a9971e Check for error; remove code duplication 2018-09-10 08:46:42 -04:00
Jason Franklin
7c8c811f00 Edit the help file 2018-09-10 08:33:10 -04:00
Phil Runninger (mac)
c726ec7318 Implement PR review comments. 2018-09-10 06:57:39 -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
Jason Franklin
b10c61b063
Merge pull request #877 from scrooloose/replace_gt_with_tabnext
Use {count}tabnext to allow users to remap gt.
2018-08-25 09:18:08 -04:00
Phil Runninger (mac)
18071f5999 NERDTreeCWD: reset CWD if changed by NERDTreeFocus
When the user has `'autochdir'` turned on, opening a new NERDTree will
cause the current working directory to change. To prevent this
happening, remember the CWD and reset it if NERDTreeFocus caused it to
change.
2018-08-22 17:01:08 -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
Phil Runninger
e653a68270
Merge pull request #867 from aflock/aflock/reword-renamed-buffer
Reword renamed-buffer prompt to be more clear
2018-08-04 15:13:46 -04:00
Andrew Flockhart
9e9d16a38a Reword renamed-buffer prompt to be more clear 2018-08-04 01:16:46 -04:00
Jason Franklin
43d569195c
Merge pull request #866 from lifecrisis/bm_toggle 2018-08-03 14:04:57 -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
eee179f0bf
Merge pull request #856 from scrooloose/broken_sort_#277
Fix issues with sorting of nodes
2018-07-31 14:53:40 -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
Phil Runninger (mac)
703e1ef4fe Correctly check the type of the sort key's value. Fixes #842. 2018-07-01 19:55:26 -04:00
Phil Runninger
d6032c876c
Merge pull request #853 from bubba-h57/master
Better OSX detection
2018-06-15 12:04:30 -04:00
Bubba
08db3a0eea Do not need to check for unix os here. 2018-06-15 12:02:58 -04:00
Bubba
a053179d6a Use the case-insensitive regex 2018-06-15 11:29:09 -04:00
Bubba
c0d87db309 Better OSX detection 2018-06-15 10:43:20 -04:00
Phil Runninger
26abd33ad9
Merge pull request #852 from mnussbaum/fix_maybe_missing_map
Bugfix - ensure keymaps dictionary exists before using it
2018-06-12 18:34:52 -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