Closed petobens closed 5 years ago
Topen
creates a new buffer in a new window, since you have the autocmd
on this event, your global variable will be re-created.
You could use :noautocmd Topen
to open the new neoterm without re-creating your global variable.
:h BufWinEnter
for reference:
After a buffer is displayed in a window. This can be when the buffer is loaded (after processing the modelines) or when a hidden buffer is displayed in a window (and is no longer hidden). Does not happen for |:split| without arguments, since you keep editing the same buffer, or ":split" with a file that's already open in a window, because it re-uses an existing buffer. But it does happen for a ":split" with the name of the current buffer, since it reloads that buffer.
Makes sense. Thanks for the explanation.
Consider the following minimal vimrc:
Now do the following: i) Open nvim on any empty python file
bar.py
and run:echo $FOO
. This returnsfoo
ii) Run:unlet $FOO
and run:echo $FOO
. Now this returns and empty string (i.e the variable is unset) iii) Runbotright Topen
and run:echo $FOO
. Now this returnfoo
.In the last step I expect
:echo $FOO
to return an empty string and not to repopulate the environment variable. I guess that somewhere inneoterm#open()
you are returning to the python file which therefore triggers the autocommand that reset the env variable.Thanks in advance for looking into this. Let me know if you can reproduce it.