kassio/neoterm

Opening a new terminal without mod replaces the current buffer id

Closed this issue · 6 comments

With the default neoterm settings and with :set hidden, running :Tnew or any command that results in creating a new terminal ends up replacing the current buffer completely (essentially stealing its buffer id and replacing the buffer that was previously focused).

This seems like a bug to me: opening a new terminal should not evict a buffer from the list of open buffers. It basically forces the user to re-open the file that was being edited).

I understand that the new terminal is opened in the current window and that it hides the current buffer, but the previously active buffer should still show up in :ls (with the same buffer id as before) and the new terminal should grab a new, unused buffer id.

Note: when using e.g. let g:neoterm_default_mod='belowright', things behave as expected: the terminal buffer gets assigned a new buffer id.

will commented

Thanks for the belowright workaround

This is not a bug. This is the defafult behaviour documented, and actually it was required by other users. Your solution is the recommend one to avoid hijacking the current buffer.

To make sure I'm crystal clear about what I meant: I agree replacing the current visible buffer is a sane default, what feels odd is that :Tnew essentially runs :bw[ipeout] on the current buffer. Quoting :h :bwipeout:

Like :bdelete, but really delete the buffer.  Everything
related to the buffer is lost.  All marks in this buffer
become invalid, option settings are lost, etc.  Don't use this
unless you know what you are doing.

Is that what you meant? If so, it seems to me that this is too destructive for a default behavior, and I would be interested in knowing which use case requires this behavior.

Note that I read :h neoterm top to bottom but could not find this behavior documented anywhere. Is there another place containing related information?

(note that I have absolutely no vested interest here as things are working perfectly fine for me now, I'm just trying to see if it would help the project to tweak the default behavior)

This especially awkward if you run :Tnew in a readonly buffer (like a help file). It throws an error every time.

Error detected while processing function newterm#new[23]..12
line    4:W10 Warning: Changing a readonly file

Default behavior was changed to replace the current window without deleting the current buffer. Sorry for delaying so much on fixing that.

Nice, thanks for addressing this!