Trim filenames created via the fs_menu (#1243)

The default when naming a file in the command line is that extra white
space will be stripped away. It seems logical for file naming via the
fs_menu in nerdtree to follow that convention.

I have left the defaults of `trim` because they seem sensible.

Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>
This commit is contained in:
Sharla Kew 2021-08-13 00:18:53 +01:00 committed by GitHub
parent 2c14ed0e15
commit 0e71462f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -5,6 +5,7 @@
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
--> -->
#### 6.10 #### 6.10
- **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243)
- **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249) - **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249)
- **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236) - **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236)
- **.8**: Put `Callback` function variables in local scope. (PhilRunninger) [#1230](https://github.com/preservim/nerdtree/pull/1230) - **.8**: Put `Callback` function variables in local scope. (PhilRunninger) [#1230](https://github.com/preservim/nerdtree/pull/1230)

View File

@ -169,7 +169,7 @@ endfunction
function! NERDTreeAddNode() function! NERDTreeAddNode()
let curDirNode = g:NERDTreeDirNode.GetSelected() let curDirNode = g:NERDTreeDirNode.GetSelected()
let prompt = s:inputPrompt('add') let prompt = s:inputPrompt('add')
let newNodeName = input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file') let newNodeName = trim(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file'))
if newNodeName ==# '' if newNodeName ==# ''
call nerdtree#echo('Node Creation Aborted.') call nerdtree#echo('Node Creation Aborted.')
@ -206,7 +206,7 @@ function! NERDTreeMoveNode()
let newNodePath = input(prompt, curNode.path.str(), 'file') let newNodePath = input(prompt, curNode.path.str(), 'file')
while filereadable(newNodePath) while filereadable(newNodePath)
call nerdtree#echoWarning('This destination already exists. Try again.') call nerdtree#echoWarning('This destination already exists. Try again.')
let newNodePath = input(prompt, curNode.path.str(), 'file') let newNodePath = trim(input(prompt, curNode.path.str(), 'file'))
endwhile endwhile
@ -337,7 +337,7 @@ endfunction
function! NERDTreeCopyNode() function! NERDTreeCopyNode()
let currentNode = g:NERDTreeFileNode.GetSelected() let currentNode = g:NERDTreeFileNode.GetSelected()
let prompt = s:inputPrompt('copy') let prompt = s:inputPrompt('copy')
let newNodePath = input(prompt, currentNode.path.str(), 'file') let newNodePath = trim(input(prompt, currentNode.path.str(), 'file'))
if newNodePath !=# '' if newNodePath !=# ''
"strip trailing slash "strip trailing slash