Commit Graph

289 Commits

Author SHA1 Message Date
Phil Runninger
2d7cb043d4
Prevent unneeded tree creation in :NERDTreeToggle[VCS] <path> (#1101)
* Don't recreate the NERDTree if its root is the same as being requested.

* Use single quotes per Vint's style recommendation.

* Update version number in changelog.

* Use a simpler method of getting the NERDTree root path.

* Remove variable. Just compare agains the function call's result.
2020-04-13 17:05:27 -04:00
lifecrisis
f767dd34a0
Add missing calls to the shellescape() function (#1099)
* Improve "g:NERDTreeQuickLook()"

The following improvements were made...

  - Use variable sigils
  - Shorten a local variable name
  - Prefer an early return over testing for a negative
  - Switch to single quotes
  - Call "shellescape()" to pass a command argument [IMPORTANT!]

The final change is a critical fix for the security and reliability
of this function (see ":h system()").

Similar fixes for the other functions in this script will follow.

* Improve "g:NERDTreeRevealInFinder()"

This commit makes several style improvements and adds a missing call
to the "shellescape()" function.

See also: 56cfbcff1e

* Improve "g:NERDTreeExecuteFile()"

Refer to: 56cfbcff1e

* Improve "g:NERDTreeRevealFileLinux()"

Refer to: 56cfbcff1e

* Improve "g:NERDTreeExecuteFileLinux()"

Refer to: 56cfbcff1e

* Properly reveal "/" on Linux

This commit handles the edge case where a user invokes the "reveal"
function on "/" on a Linux box.  There is nothing to do but open the
root directory itself since "/" has no parent.

* Update the "CHANGELOG.md" file

* Add final missing "shellescape()" calls

I initially thought that there were several more locations where
a call to "shellescape()" was required but omitted.  However, there
are only two.  I suppose I should have taken the time to look.

Fixing these was easy.  I would be surprised if this change breaks
anything on the user side.

* Update the "CHANGELOG.md" file (again)

Use a more fitting description of the change...
2020-04-09 21:37:55 -04:00
Rolando
832bbaa729
Fix vsplit to not open empty buffer (#1098)
* Fix vsplit to not open empty buffer

* Add changelog entry
2020-04-01 01:21:37 -04:00
Phil Runninger
c3d7c141bb Simplify and make similar statements more similarer 2020-02-03 09:30:08 -05:00
Phil Runninger
450abd1820 Fix indentLevelFor(), which was getting the right answer the wrong way. 2020-02-03 08:00:06 -05:00
Phil Runninger
6d3743549c Fix vint errors: Use robust operators ==# and !=# 2020-02-03 02:28:53 -05:00
Phil Runninger
26333ceeab If arrows are empty strings, don't print their trailing spaces. 2020-02-03 01:58:00 -05:00
Phil Runninger
e48b5728f9 NERDTree <start-directory> always sets NERDTree root. 2020-01-28 03:55:58 -05:00
Phil Runninger
5fbf0d7dba Put the eventignore reset inside a finally block to ensure it's called. 2020-01-16 10:51:12 -05:00
Phil Runninger
b579c7751d Fix regex that finds keyword for minimal menu. 2020-01-06 09:19:25 -05:00
Caleb Maclennan
907587f7a3 Fix lint warnings: use the full option name 2019-12-31 10:30:00 +03:00
Caleb Maclennan
a722613f36
Fix lint warnings: use robust operators 2019-12-31 09:42:19 +03:00
Caleb Maclennan
45e33f2502
Fix lint warnings: prefer single quoted strings 2019-12-31 09:42:14 +03:00
Caleb Maclennan
8d81510aa6
Fix VimL syntax error: undefined variable 2019-12-31 09:41:46 +03:00
Phil Runninger
c962796b03 Ensure backward compatibility. v:t_func is not available before 8.0. 2019-12-16 09:04:16 -05:00
Alejandro Sanchez
a7886fb6c4 Allow use of function references as callbacks (#1067) 2019-12-14 20:25:17 -05:00
Phil Runninger
371feb7e54
Support tab-specific CWDs (#1032)
* Change CWD when switching tabs to the tab's NERDTree root.

* Remove commented-out code.

* List the new possible value for NERDTreeChDirMode in doc.

* Add new option to select between `:cd` and `:tcd`.

* Document the new NERDTreeUseTCD option.

* Update version number in change log.
2019-10-16 13:26:20 -04:00
Phil Runninger
4fe24d3156
Wrap saveScreenState's statements in a try-catch block. (#1047)
* Wrap saveScreenState's statements in a try-catch block.

If you're in NERDTree, and you press : to open a command line, and then
press Ctrl+F to open the [Command Line] window, you will see errors
related to switching windows while in this function. (Those commands are
not allowed while in the [Command Line] window.) The try-catch block
handles the errors, preventing their being displayed.

* Update version number in change log.
2019-10-08 14:01:50 -04:00
Phil Runninger
5af6859846
Reintroduce necessary variable mistakenly removed. (#1040)
* Reintroduce lost variable: splitMode.

* Add a space between splitMode and "split". `verticalsplit` is invalid.

* Update version number, and add attributions (PR authors)
2019-09-26 08:47:36 -04:00
Phil Runninger
bd744eab8d
Make the behavior of window splits consistent (#1035)
* add option to spawn split from previous window

* Update some comments and remove debugging statement.

* Simplify the code, and make it respect NERDTreeWinPos and 'splitbelow'.

* Better logic for getting NERDTree window number when not active window.

* Use common functions for splitting windows. Make splitting respect user.

The placement of split windows now respects the user's choices for the
splitright and splitbelow settings, and the g:NERDTreeWinPos variable.

* Update version number in change log.
2019-09-24 01:19:27 -04:00
Chris Patuzzo
2eaedd8bf4 Fix (p)ath not displaying in the minimal menu (#1038)
The ‘copy (p)ath to clipboard’ menu item was added
recently in this pull request:
https://github.com/scrooloose/nerdtree/pull/1002/files

However, this caused the NERDTreeMinimalMenu to
display ‘copy’ instead of ‘(p)ath’ because it was
simply using the first word of the item’s text.

This change fixes that bug by using a regex to
pick out the first word beginning with ‘(’
2019-09-15 14:41:27 -04:00
Phil Runninger
60ec10b477
Enable events when closing NerdTree window. (#1037)
* Enable events when closing NT window. Triggers updates in Airline.

* Update version number in change log.
2019-09-13 10:49:26 -04:00
Phil Runninger
3d508aedce
Fix the e key mapping to use netrw if desired (#1031)
* Use :edit in openExplorer to allow NERDTreeHijackNetrw to do its thing.

* Remove commented-out code.

* Make `e` work on file nodes, opening a new NERDTree or netrw buffer.

* Update change log.
2019-08-27 20:53:23 -04:00
Phil Runninger (mac)
9afab6257b Condense code: ternary operators vs. if-then-else blocks. 2019-08-19 14:39:17 -04:00
Phil Runninger
c4a7ca084e
Add file extension and size to sorting capabilities (#1029)
* Add ability to sort by extension and file size.

Use the tags [[extension]], [[size]], or [[-size]] in the
g:NERDTreeSortOrder list to accomplish this sorting.

* Prevent metadata tags being misused in getSortOrderIndex().

* Apply metadata tags only to files.

* Update NERDTreeSortOrder in help file.

* Update version number in CHANGELOG.
2019-08-19 03:51:34 -04:00
Phil Runninger
ae1c0004ec
Suppress events for intermediate window/tab/buffer changes (#1026)
* Add an optional parameter to neredtree#exec to suppress all events.

The value doesn't matter, but 1 is a good choice. Its presence is an
indicator that tells NERDTree to tell Vim to ignore all events. I'm not
yet sure if there needs to be an else section to that if block. It may
be OK to allow all events to fire in the right situations.

* Supress events in all intermediate nerdtree#exec calls.

Finding all the right function calls is the key here.

* Make ignoreAll a required parameter to nerdtree#exec().

* Put required ignoreAll argument (==0) in where it's now needed.

* Ignore events when creating a new vertical split.

* Ignore events when closing NERDTree. This may need to be reverted.

* Remove debugging statment and commented-out code.

* Wrap remaining buffer/window-switching commands in nerdtree#exec().

* Update version number.

* Add a space between arguments in nerdtree#exec() calls.
2019-08-08 22:00:35 -04:00
Phil Runninger
63c59208c1
Revert #1019 to fix nvim artifacts and flickering. (#1021)
* Revert "Use :mode only in neovim. MacVim still needs to use :redraw! (#1019)"

This reverts commit 4ac07f52a3.

* If not Neovim, use `:redraw!` as was done before.

* Update version number.

* Fix punctuation in NERDTree Menu instructions.
2019-07-14 15:17:56 -04:00
Phil Runninger
4ac07f52a3
Use :mode only in neovim. MacVim still needs to use :redraw! (#1019)
* Use :mode only in neovim. MacVim still needs to use :redraw!

* Make nerdtree#redraw do both redraw and redraw! based on a parameter.

* Make bang a required parameter.

* Replace all redraw statments with call nerdtree#redraw function calls.

* Update version in change log.
2019-07-10 09:45:58 -04:00
Phil Runninger
3b1a850b85
Use :mode instead of :redraw! when updating menu. (#1016)
* Use :mode instead of :redraw! when updating screen.

In neovim, it will actually clear the whole screen, whereas, redraw!
does not.

* Update version number in change log.
2019-07-07 03:19:17 -04:00
Phil Runninger
89a1a4355b
When searching for root line num, stop at the end of the file. (#1015)
* When searching for root line num, stop at the end of the file.

When using the following NERDTreeStatusLine, Vim would lock up and not
work anymore. The problem was that when trying to find the root line
number, the loop was continuing past the end of the file, looping
"forever". The fix was to simply stop at the end of the file.

let g:NERDTreeStatusline = "%{exists('g:NERDTreeFileNode')&&" .
      \ "has_key(g:NERDTreeFileNode.GetSelected(),'path')?" .
      \ "g:NERDTreeFileNode.GetSelected().path.getLastPathComponent(0):''}"

* Update change log.
2019-07-04 00:21:50 -04:00
Phil Runninger
cce6fb373f
Expand functionality of <CR> mapping (#1011)
* Define default values for new variables governing new "Default Open".

"Default Open" means to open a file with the Enter key (which of course
can be changed.) The key can be changed in the vimrc, and there is a
variable for specifying the Opener parameters for opening the node. This
lets the user decide whether Enter (or another key) will open a file in
the current tab or a new one, and whether or not to open the file again
in the tab or jump to a window where the file is already open.

* Remove the old mapping for <CR>, a duplicate of 'o'.

<CR> will be defined like all the other keys, in plugin/NERD_tree.vim

* Assign functions to the new <CR> key mapping.

Three separate functions handle directories, files, and bookmarks.

* Rename variables: NERDTreeCustomOpen and NERDTreeCustomOpenArgs

* Add documentation for NERDTreeCustomOpenArgs and NERDTree-<CR>.

* Make key mapping variables be indexed in the Vim help

* Remove angle brackets from <CR> to see if help navigation improves.

* Rename functions from defaultOpen... to customOpen...

* Use separate options for file and directory nodes.

* Update documentation for separate file/directory options.

* Update version number and change log.

* Change CR to <CR> in help tags.

* Fix missing backtick in patch number.

* Update the quickhelp text.

* Update Pull Request template.

* Update change log with simpler formatting of patch number.

* Get NERDTree version number directly from CHANGELOG.md

* Reformat the lists of contributors in the Change Log.

* Initialize the version text, just in case the while loop finds nothing.
2019-07-01 22:13:20 -04:00
Phil Runninger
2cbc76bbfd
Fix NERDTree opening with the wrong size. (#1008)
* Fix NERDTree opening with the wrong size.

There were two commands that seemed to be causing the NERDTree window to
open in exactly half the screen width. They are:

- silent! execute 'edit ' . t:NERDTreeBufName        in _createTreeWin()
- setlocal nobuflisted                         in _setCommonBufOptions()

These commands were reseting the width of NERDTree. The solution I chose
was to resize the window after creating the new window, and then to set
winfixwidth before setting the other common buffer options.

* Update change log and version number.
2019-06-27 01:34:10 -04:00
Phil Runninger
9bedadd062
Refresh a dir_node if the file wasn't found in it, and look once more. (#1005) 2019-06-18 10:27:00 -04:00
Phil Runninger
70dc34cb69
Enable root refresh on "vim ." a different way than #999. (#1001)
* Fix "R doesn't work when doing 'vim <folder>'" a different way.

Instead of assigning a value to t:NERDTreeBufName for a window tree,
which is used to determine if NERDTree is open, simply also look at the
current buffer's name to see if it matches the NERDTree pattern.

* Replace hardcoded buffer name prefix with BufNamePrefix() function.
2019-06-13 09:16:56 -04:00
Phil Runninger
28eb47e267
Fix refreshroot (#999)
* Set t:NERDTreeBufName when creating a window tree.

* Change folding markers.
2019-06-07 21:41:47 -04:00
Phil Runninger
a3f0e66793
Change minimum vim (#991)
* Add a new function to implement and() from vim 7.4.

* Change minimum required version of vim to 7.3.
2019-05-09 10:12:25 -04:00
Phil Runninger (mac)
3c06335782 Escape the DirArrow strings in substitute function. 2019-04-23 10:26:30 -04:00
Phil Runninger
9226eab2a8
Allow multi-character DirArrows (#985)
* Add debugging messages to diagnose issue #931.

* Echo the CWD and NERDTree root too.

* Ensure DirArrows are trimmed to a single character.

Actually, it's up to the user to make sure it's a single character after
leading and trailing spaces are removed. Spaces need to be removed so
that an accurate level of indentation can be calculated.

* Remove debugging statements

* Simplify the algorithm for calculating indentation level.

1. Replace the DirArrows with a single space.
2. Count the leading spaces.
3. Divide by 2.

This allows users to specify multi-character arrows, where a spaces
prevent characters printing on top of each other.
2019-04-22 15:58:06 -04:00
Phil Runninger
e126b8745d
Remove redraw! while still clearing last message empty string. (#979) 2019-04-16 09:55:20 -04:00
Phil Runninger (mac)
7513f256aa Fixes #970. Restore silent parameter to _initChildren.
https://github.com/ryanoasis/vim-devicons uses this function directly
with silent set to 1.
2019-03-26 11:57:21 -04:00
Terry Ding
839cddc750 fix _initChildren function value set to numChildrenCached error (#969) 2019-03-26 02:03:12 -04:00
Phil Runninger
e3e600608a
On Windows, do a case-insensitive comparison of paths. (#967) 2019-03-25 22:32:07 -04:00
Phil Runninger
0efbdfbc5a
Remove the "Please wait... DONE" messages. (#966) 2019-03-25 22:29:21 -04:00
Chris Patuzzo
84737f2ebe Add a NERDTreeMinimalMenu feature (#938)
* Extract the menu action prompts to a function

* Add a NERDTreeMinimalMenu configuration option

If this option is set, Vim’s command line displays
a single-line version of the menu:

Which action? (a*/m/d/r/o/q/c/l):

Pressing ‘a’ will call the ‘add child node’ menu
item as that is its shortcut.

The * denotes the position of the currently
selected menu item which can be changed with
NERDTreeMenuDown and Up in the usual way.

The user may wish to set these to <left>, <right>
or h, l if they prefer.

* Minimise the text once a menu item is chosen

If NERDTreeMinimalMenu is set, then echo a single
line prompt after the menu item is chosen. This
reduces noise for users who are already familiar
with how the menu works and prevents Vim scrolling
down to accommodate the menu text.

If the directory is non-empty we display
‘Delete directory?’ instead of ‘Delete?’ and the
user must still type ‘yes’ to confirm, rather than
just pressing ‘y’.

* Document the new NERDTreeMinimalMenu feature

* Tweak the format for the minimal menu prompt

As per @PhilRunninger’s suggestions:

- The menu now shows the ‘j/k/enter’ help text
- The first word of the selected item is shown*
- Use commas between menu items so that it’s
  visually distinct from the ‘j/k/enter’ text

* I tried displaying the full menuItem text, but
this can be quite long, e.g.

> (o)pen the current node with system editor

This causes the menu to jump around a lot. We
could add another minimal versions of these, but
I think the first word seems ok for now.
2019-02-24 18:01:12 -05:00
Phil Runninger
b6cde142dd
Preview bookmarks (#956)
* Add function to preview bookmarks.

File bookmarks are previewed like regular file nodes.
Directory bookmarks are located with NERDTreeFind in the current tree.

* Update help doc to include the new bookmark preview functionality.
2019-02-22 08:21:20 -05:00
Phil Runninger
9eda9ce6a1
Add new value to NERDTreeQuitOnOpen to close bookmark table (#955)
* Update documentation for new NERDTreeQuitOnOpen values.

* Modify use of NERDTreeQuitOnOpen, keeping current behavior.

* If applicable, close the bookmarks table before opening the target.
2019-02-21 07:47:15 -05:00
Phil Runninger
2e0b101d57
Add an :EditBookmarks command to edit the bookmarks file (#954)
* Add a new NERDTree buffer command to edit the bookmarks file.

* Update the mini-help panel with missing bookmark commands.

* Update the help file with the new :EditBookmarks command.
2019-02-20 23:57:51 -05:00
Phil Runninger
c05615fd80
Set a maximum window size when zooming. (#950) 2019-02-15 03:10:28 -05:00
Phil Runninger
74be22deb7
Escape a backslash so it can be used in a key mapping. (#948) 2019-02-14 15:28:30 -05:00
zcodes
8cc154d4b0 fixed root path error for windows (#935)
* fixed root path error for windows

* simplify condition check
2019-02-01 07:50:55 -05:00