Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NERDTreeFind fails with vim-startify or empty buffer #1059

Closed
andys8 opened this issue Nov 21, 2019 · 12 comments · Fixed by #1081
Closed

NERDTreeFind fails with vim-startify or empty buffer #1059

andys8 opened this issue Nov 21, 2019 · 12 comments · Fixed by #1081

Comments

@andys8
Copy link
Contributor

andys8 commented Nov 21, 2019

Description

:NERDTreeFind prints this error when used with vim-startify. My guess is this is related.

image

Possible related, because it's working fine with not exisiting/written files:
#1043

@willfindlay
Copy link
Contributor

I'm actually also getting this issue but without vim-startify.

@andys8
Copy link
Contributor Author

andys8 commented Nov 24, 2019

@willfindlay What's in your buffer when this issue occurs?

@andys8
Copy link
Contributor Author

andys8 commented Jan 19, 2020

This happens with an empty buffer, too. You can reproduce the error like this:

$ echo "new buffer" | vim -
:NERDTreeFind

E716: Key not present in Dictionary: putCursorHere

I basically want the behavior of :NERDTreeFind - but to fail silently in case the file isn't saved or is not a file. Is there currently a way to achieve this or could it be done with an extra command or argument? @PhilRunninger :)

@andys8 andys8 changed the title NERDTreeFind fails with vim-startify NERDTreeFind fails with vim-startify or empty buffer Jan 19, 2020
@andys8
Copy link
Contributor Author

andys8 commented Jan 19, 2020

The absolut best thing would be if :NERDTreeToggle could be highlighting the current file, if it exists, otherwise just toggles. Not sure if it's currently possible.

@andys8
Copy link
Contributor Author

andys8 commented Jan 19, 2020

Also :NERDTreeFind in nerdtree itself on a file jumps to the containing directory. It looks like random, side-effecty behavior and not intended.

andys8 added a commit to andys8/nerdtree that referenced this issue Jan 19, 2020
There was a fix in preservim#1043 which improves the behavior for non saved
filenames. Those are not on disk, but also not empty. This lead to an
issue preservim#1059 where actual "empty files" like created with vim-startify or
stdin lead to an error. This change fixes this by adapting the order of
the tests. It'll print "no file for the current buffer" for empty files.

Solves preservim#1059
@andys8
Copy link
Contributor Author

andys8 commented Jan 19, 2020

The last few comments of myself are probably different feature requests or maybe can be achieved with vimscript. I created a PR to fix the root issue and fail with the wanted error message to close this issue.

andys8 added a commit to andys8/nerdtree that referenced this issue Jan 20, 2020
There was a fix in preservim#1043 which improves the behavior for non saved
filenames. Those are not on disk, but also not empty. This lead to an
issue preservim#1059 where actual "empty files" like created with vim-startify or
stdin lead to an error. This change fixes this by adapting the order of
the tests. It'll print "no file for the current buffer" for empty files.

Solves preservim#1059
@tbergeron
Copy link

tbergeron commented Jan 25, 2020

I have the same issue when using :NERDTreeFind in an empty buffer. I understand why it happens but it would be great to have a way of achieving this:

The absolut best thing would be if :NERDTreeToggle could be highlighting the current file, if it exists, otherwise just toggles. Not sure if it's currently possible.

EDIT: I don't have vim-startify though.

@andys8
Copy link
Contributor Author

andys8 commented Jan 25, 2020

@tbergeron if you want to, you can try out the PR #1081 I submitted. I'm confident it should fix the issue, and also might be merged soon. Positive feedback would be nice, though.

@tbergeron
Copy link

@andys8 I tried your PR and it shows: NERDTree: no file for the current buffer instead of opening the current directory. Is that the desired behavior? Before, it would show the error but then it would open the tree view. Now it just shows the error message. Thanks

@andys8
Copy link
Contributor Author

andys8 commented Jan 26, 2020

That's the intended behavior. I guess it was like this before it was broken, too. Thanks for testing.

@tbergeron
Copy link

@andys8 oh I see! 🤣 I thought it would open the current directory if no file is opened in the buffer. I wish there would be some way to toggle to the current opened file. Good job fixing that bug though :P

@andys8
Copy link
Contributor Author

andys8 commented Jan 28, 2020

Thanks @PhilRunninger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants