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

Error when opening command window with mapping in NERDTree buffer #1046

Closed
8 tasks done
Chris-Slade opened this issue Oct 7, 2019 · 2 comments · Fixed by #1047
Closed
8 tasks done

Error when opening command window with mapping in NERDTree buffer #1046

Chris-Slade opened this issue Oct 7, 2019 · 2 comments · Fixed by #1047
Labels

Comments

@Chris-Slade
Copy link

Self-Diagnosis

  • I have searched the issues for an answer to my question.
  • I have reviewed the NERDTree documentation. :h NERDTree
  • I have reviewed the Wiki.
  • I have searched the web for an answer to my question.

Environment (for bug reports)

  • Operating System: macOS 18.7.0
  • Vim/Neovim version :echo v:version: 810 (patches 1-2050)
  • NERDTree version, found on 1st line in NERDTree quickhelp ?: 6.1.1
  • vimrc settings
    • Minimal .vimrc to reproduce (using vim-plug):
    set nocompatible
    
    call plug#begin('~/.vim/bundle/')
    Plug 'scrooloose/nerdtree'
    call plug#end()
    
    noremap : q:i
    

Steps to Reproduce the Issue

  1. Open and move the cursor to a NERDTree buffer
  2. Press :

Current Result (Include screenshots where appropriate.)

You'll get the following errors before the command window opens:

Error detected while processing function 253[2]..220[2]..nerdtree#exec:
line    5:
E11: Invalid in command-line window; <CR> executes, CTRL-C quits
Error detected while processing function 253[7]..nerdtree#exec:
line    5:
E11: Invalid in command-line window; <CR> executes, CTRL-C quits

Expected Result

Command window should open without errors.

@Chris-Slade Chris-Slade added the bug label Oct 7, 2019
@PhilRunninger
Copy link
Member

NERDTree has an autocommand set up to remember the state of NERDTree when focus leaves that window, so that it can be restored when NERDTree becomes focused again. NERDTree takes the following steps, after going to the [Command Line] window:

  1. Go back to the NERDTree
  2. Record data that needs to be remembered.
  3. Return to the [Command Line] window.

The problem occurs when the script tries to leave the [Command Line] window in steps 1 and 3. That window does not allow you to enter the command NERDTree is using to switch windows: wincmd w

I don't consider this a bug, since you've redefined basic Vim functionality. You could try the following autocmd, instead of your noremap : q:i, to mitigate the error messages.

autocmd BufEnter * if &filetype != 'nerdtree' | nnoremap <buffer> : q:i| endif

@Chris-Slade
Copy link
Author

@PhilRunninger Thanks for the response. If it makes a difference, the same errors can be caused without changing any of Vim's basic behavior, besides setting nocompatible, by pressing CTRL-F after accessing the command line from a NERDTree buffer. That should be considered a bug, no?

It also seems to be a regression, since I've been using NERDTree for a while now but don't recall running into these errors until recently. A quick bisect points to 98a5d1f, but since that's from 2014 and I haven't seen these errors before the last few days, I'm thinking it possibly has something to do with my Vim version as well. (I recently upgraded both NERDTree and Vim.) I'll look into it more tonight when I have access to my other machine, to see how it works across different versions of Vim.

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

Successfully merging a pull request may close this issue.

2 participants