Skip to content

Directories and files starting with a tilde will not be expanded/opened #1445

@Arteneko

Description

@Arteneko

Self-Diagnosis

i've searched on various platforms including those issues but cannot find anything on the topic.

Edit: added another case where this bug appears.

Environment

let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')

if !filereadable(vimplug_exists)
	echo "Installing Vim-Plug..."
	echo ""
	silent exec "!\curl -fLo " . vimplug_exists . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
	let g:not_finish_vimplug = "yes"

	autocmd VimEnter * PlugInstall
endif

call plug#begin(expand("~/.config/nvim/plugged"))

Plug 'scrooloose/nerdtree'

call plug#end()

" File browser
let g:NERDTreeChDirMode = 2
" let g:NERDTreeMinimalUI = 1
let g:NERDTreeAutoDeleteBuffer = 1

Steps to Reproduce the Issue and Current Behavior

For folders
  1. Have a folder starting with a tilde and a file (e.g. ~dir/test)
  2. Open the NERDTree browser (:NERDTreeToggle)
  3. Try to expand the folder by pressing enter on it

It will indicate that the directory is open but show no file inside.

For files
  1. Have a file starting with a tilde (e.g. ~test)
  2. Open the NERDTree browser (:NERDTreeToggle)
  3. Select the file

It will log the error below; pressing ENTER to dismiss it will still open the file.

E79: Cannot expand wildcards                                                                                                                           
Press ENTER or type command to continue

Note: Opening ~dir/test or ~test from the CLI (nvim ~dir/test ...) throws no error at init but the Tree bugs described above stil trigger.

From within the editor

When in the editor with NERDTree closed and in a project containing files or dirs starting with the tilde, if editing a file within a tilde-prefixed dir, if the file is of depth of 1 (i.e. is at ~dir/file), the error below is produced.

Error detected while processing function <SNR>49_findAndRevealPath:                                                                                    
line   49:                                                                                                                                             
E716: Key not present in Dictionary: "putCursorHere"

However, if the file is at depth of 2 or more (i.e. at ~dir/another-dir/file), another error given below occurs.

Error detected while processing function <SNR>49_findAndRevealPath[47]..164[28]..164:                                                                  
line   28:                                                                                                                                             
E716: Key not present in Dictionary: "reveal"                                                                                                          
Error detected while processing function <SNR>49_findAndRevealPath:                                                                                    
line   49:                                                                                                                                             
E1203: Dot can only be used on a dictionary: l:node.putCursorHere(1, 0)

Expected Result

Except for a single ~ as directory name, NERDTree shouldn't try to consider the tilde as anything special and expand it.
It should treat it as-is as the file or directory name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions