Skip to content

Commit

Permalink
Trim filenames created via the fs_menu
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
elanorigby committed May 10, 2021
1 parent 81f3eab commit 72e32fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
-->
#### 6.10
- **.10**: Trim filenames created via the fs_menu (elanorigby) [#1238](https://github.com/preservim/nerdtree/pull/1238)
- **.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)
- **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225)
Expand Down
6 changes: 3 additions & 3 deletions nerdtree_plugin/fs_menu.vim
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ endfunction
function! NERDTreeAddNode()
let curDirNode = g:NERDTreeDirNode.GetSelected()
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 ==# ''
call nerdtree#echo('Node Creation Aborted.')
Expand Down Expand Up @@ -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 = input(prompt, curNode.path.str(), 'file')
let newNodePath = trim(input(prompt, curNode.path.str(), 'file'))
endwhile


Expand Down Expand Up @@ -337,7 +337,7 @@ endfunction
function! NERDTreeCopyNode()
let currentNode = g:NERDTreeFileNode.GetSelected()
let prompt = s:inputPrompt('copy')
let newNodePath = input(prompt, currentNode.path.str(), 'file')
let newNodePath = trim(input(prompt, currentNode.path.str(), 'file'))

if newNodePath !=# ''
"strip trailing slash
Expand Down

0 comments on commit 72e32fe

Please sign in to comment.