kassio/neoterm

[N]T... or t:neoterm_id problem?

monkoose opened this issue · 10 comments

Describe the bug
When i want to send command to specific t:neoterm_id that is not currently there as example lets say 5 with :5T .... or just open this specific neoterm id with :5TOpen or toggle it with :5Ttoggle then this all commands produce errors

Error detected while processing function neoterm#open[2] .... toggle[2] .... do[3].... exec[2] etc

E121:  Undefined variable: t:neoterm_id
E116: Invalid arguments for function printf

And it just creates noterm-1 if there is no other terminal buffers or neoterm-2 if there is already neoterm-1 buffer, and so on.
Then you can send to this terminal buffer without errors, but if you closed previous buffer with its content you receive neoterm warning echo message something like this neoterm-2 not found (probably already closed). So if you send again with :5T ls (receiving above echo) and then open with :5Topen there is not output of the command in this terminal buffer.
Bug or i'm doing something wrong?

Expected behavior
Just create new terminal buffer with this specific t:neoterm_id and works as it should for command send to it/open/toggle etc.

Versions (please complete the following information):

  • OS: Archlinux
  • Neovim v.0.4.2
  • latest neoterm

Hi there,

First of all thanks for the suggestion. Although, the neoterm_id wasn't designed to be assigned by the user. These ids are auto-incremental, so given the user the power to assign a random id would mess with the auto-incremental logic, which I don't see as desired.

Sorry, just notice that I missed one part of the issue.

I'll work on fix the problem on sending commands to a closed the neoterm

And it just creates noterm-1 if there is no other terminal buffers or neoterm-2 if there is already neoterm-1 buffer, and so on.
Then you can send to this terminal buffer without errors, but if you closed previous buffer with its content you receive neoterm warning echo message something like this neoterm-2 not found (probably already closed). So if you send again with :5T ls (receiving above echo) and then open with :5Topen there is not output of the command in this terminal buffer.
Bug or i'm doing something wrong?

The expected behaviour is:

  1. When there's no existing neoterm buffer and the user tries to send a command with an inexistent target, like :5T ls, it'll create the first buffer and send the first command anyways. This ensures that your first command always run.
  2. When there's already one or many neoterm buffers and the user tries to send a command with an inexistent target, the error message will appear: neoterm-5 not found (probably already closed)

The exception mentioned on the description is a bug and will be fixed, but the behaviour won't change.

Can you please update your neoterm and test it again, please?

Will test it later today.

Although, the neoterm_id wasn't designed to be assigned by the user. These ids are auto-incremental, so given the user the power to assign a random id would mess with the auto-incremental logic, which I don't see as desired.

Sorry maybe it is language barrier, but what does this means then? Which id is it then?

:[N]Topen :Topen
Opens the neoterm with id [N]. With no [N] the last active neoterm will be
opened or a new one will be created. This command accepts vim |mods|. The last
|mods| used will be saved in the neoterm instance.

Where to actually look for this id [N]?

In the process of testing. Seems like first part of the issue is gone - there is no error after invoking :5Topen. But still if i toggled/closed it and then send :5T ls i got message neoterm-5 not found ....

What this help means then?

:[N]T {cmd} :T
Executes the given command on the neoterm with id [N]. With no [N] the last
active neoterm will be used (or a new one will be created). If a new neoterm
window is created, mods are accepted to position the new window. If there is a
% in the given command, this will be expanded to the current file path.

To actually make it works i need recursively open and close 5 terminal windows :1Topen :2Topen :3Topen :4Topen :5Topen then it can without a problem send command to 5T and any terminal below, but if i again want to send to higher number like T8 ls - message neoterm-8 not found... appears.

Executes the given command on the neoterm with id [N]

The terminal must exist to send the command, not the other way around. The only exception is for the first terminal. So yes, you'll only be able to send a command to neoterm-5 if it already exists:

neoterm

Ok i understood this. So its actually impossible to preconfig something to send not to default terminal that you can toggle with say some mapping. Because [N]Topen only will increment the number of last t:neoterm_id before it reach this N.
:( Then maybe i missed some part of the doc, or it is misguided. Because for each command that accepts [N] it says it will open terminal with this ID, and there is nothing about that it works only for previously opened ids.

Anyway thank you for this plugin, it really convenient for me to toggle terminal window.