nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 7eee457efae1bf9b96d7a266ac097639720a68fe
parent aa7e97b7ff2ace7ed434b09bd33f3ad449d294e9
Author: Phil Runninger <PhilRunninger@users.noreply.github.com>
Date:   Tue, 14 Sep 2021 22:34:57 -0400

Replace trim() with a version-compatible alternative. (#1265)

* Replace trim() with a version-compatible alternative.

* Update version number in change log.
Diffstat:
MCHANGELOG.md | 1+
Mnerdtree_plugin/fs_menu.vim | 6+++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -5,6 +5,7 @@
         - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
 -->
 #### 6.10
+- **.14**:  Replace trim() with a version-compatible alternative. (PhilRunninger) [#1265](https://github.com/preservim/nerdtree/pull/1265)
 - **.13**: Change highlighting of bookmarks in the tree. (PhilRunninger) [#1261](https://github.com/preservim/nerdtree/pull/1261)
 - **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259)
 - **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243)
diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim
@@ -169,7 +169,7 @@ endfunction
 function! NERDTreeAddNode()
     let curDirNode = g:NERDTreeDirNode.GetSelected()
     let prompt = s:inputPrompt('add')
-    let newNodeName = trim(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file'))
+    let newNodeName = substitute(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file'), '\(^\s*\|\s*$\)', '', 'g')
 
     if newNodeName ==# ''
         call nerdtree#echo('Node Creation Aborted.')
@@ -206,7 +206,7 @@ function! NERDTreeMoveNode()
     let newNodePath = input(prompt, curNode.path.str(), 'file')
     while filereadable(newNodePath)
         call nerdtree#echoWarning('This destination already exists. Try again.')
-        let newNodePath = trim(input(prompt, curNode.path.str(), 'file'))
+        let newNodePath = substitute(input(prompt, curNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g')
     endwhile
 
 
@@ -337,7 +337,7 @@ endfunction
 function! NERDTreeCopyNode()
     let currentNode = g:NERDTreeFileNode.GetSelected()
     let prompt = s:inputPrompt('copy')
-    let newNodePath = trim(input(prompt, currentNode.path.str(), 'file'))
+    let newNodePath = substitute(input(prompt, currentNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g')
 
     if newNodePath !=# ''
         "strip trailing slash