The call to "set_curterm" inside the "terminalHasColors" function breaks the EditLine configuration on some Linux distributions, causing certain characters that have functions bound to them to not show up and backspace to stop deleting characters (only visually). This patch ensures that term struct is restored after the routine for cheking if terminal supports colors is done, which fixes the aforementioned issue.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This is the second (and better) solution that addresses this issue. Previous discussions can be found here.
This change seems obviously correct. We'll still need to be careful about using this functionality on the lldb side though. This fix will only help if there is proper synchronization between using this function and libedit initialization. If we still run into issues, we'll need to either add more synchronization, or do something different altogether.
Regarding testing, I suppose it should be possible to write a unit test which checks that this function really preserves the terminal value, but it's not clear to me how useful would that be....
llvm/lib/Support/Unix/Process.inc | ||
---|---|---|
361–362 | Now that its purpose is also to restore the terminal value, this code is no longer that "silly". // Restore the current terminal to the original value. Be sure to also free the structure allocated by setupterm. |
We'll still need to be careful about using this functionality on the lldb side though. This fix will only help if there is proper synchronization between using this function and libedit initialization
The only way I think this could have adverse effects is if some component is relying on this function to clear the current settings, which would stop happening after this change.
@labath can this be merged or do we need someone else to approve it? I tagged everyone I found that could review it, but maybe we should add more people?
Ownership of various Support components is a little bit unclear, but I think this is sufficiently obvious that I'll just go ahead and commit it for you. Thanks for your patience.
Now that its purpose is also to restore the terminal value, this code is no longer that "silly".
I'd update this to something like: