p-e-w / finalterm

At last – a modern terminal emulator (NO LONGER MAINTAINED)

Home Page:http://finalterm.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Minor] Toggle button remains red after errors followed by blank lines

arkocal opened this issue · comments

Steps to reproduce:
Give a command that returns an error code.
Press enter.

It works correctly again after a command executes successfully.

Seems like this is not a GUI issue (at least not caused by anything GUI related). Moving the cursor over the dot also creates the popup with the last error code. I guess this is related to lines 391 and 396 in TerminalOutput.vala
last_command = stream_element.get_text_parameter(0, "");
var return_code = stream_element.get_numeric_parameter(0, 0);
Both return the correct values for latest executed command.

Yes, the problem is actually on the shell level, because bash itself does not reset the the value of $? until another command is executed.

This was a much deeper issue than originally suspected. Here's the full story:

  1. Newer versions of VTE install a __vte_prompt_command function in the PROMPT_COMMAND variable. Because the preexec script was appending to rather than overriding this variable, the built-in check for no-op lines did not work.
  2. Once that was fixed, Final Term's prompt detection failed because now it was no longer getting notified of no-op commands. Adding a dummy invocation of the hook fixed that problem too.

Basically, one bug was hiding another bug. Now, both bugs are fixed.