On Friday, April 12, 2024 1:37 PM, Rubén Justo wrote: >On Fri, Apr 12, 2024 at 01:24:55PM -0400, rsbecker@xxxxxxxxxxxxx wrote: >> On Friday, April 12, 2024 1:15 PM, Rubén Justo wrote: >> >Subject: [PATCH v3 1/2] launch_editor: waiting for editor message >> > >> >We have a hint shown when we are waiting for user's editor since >> >abfb04d0c7 (launch_editor(): indicate that Git waits for user input, 2017-12-07). >> > >> >After showing the hint, we call start_command() which can return with an error. >> >Then we'll show "unable to start editor...", after having said >> >"Waiting for your editor...", which may be confusing. >> > >> >Move the code to show the hint below the start_command(). >> >> My thought on this move is for esoteric (but commonly used) terminal >> emulators. If one is on a t6530, tn3270, or w3270/9 emulator, for >> example, the emulator switches modes from text on the POSIX side to >> block/full screen mode when the editor is launched. Printing a message >> after the editor has launched has the potential to dump the message >> into the terminal emulation buffer and get caught in the commit text >> comment. This is not desirable. This change could have seriously >> undesirable side-effects. > >That's a good point. Thanks for bringing it up. > >Of course, in such a situation the user has the opportunity to disable the hint. > >However, can you think of a way in which we could do this, not showing the >"Waiting..." before the "unable to start", better? I do not have a good solution. One thought was to run the Waiting message in a separate thread, but that is dangerous. Terminal I/O APIs are generally not thread aware and random results are frequent when writing from two threads, particularly in different processes. Polluting stdout is never a good idea, and in this case the encoding and terminal type could also change between git and editor, even in Linux. The only potential way to do this is with an editor aware mutex (there isn't a portable on) that would block the editor, poll the terminal state, change to UTF-8 or US-ASCII or... and write the Waiting message, switch back, then release the mutex.