git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4] launch_editor: waiting message on error

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Apr 15, 2024, 14:05 UTC
Message-ID
<beebf170-31d0-4ecf-b029-d6bc499f6da8@gmail.com>
In-Reply-To
<e208da74-8f16-44ae-912e-ae968da82057@gmail.com>
Hi Rubén
On 14/04/2024 08:39, Rubén Justo wrote:
Show 11 quoted lines
> When advice.waitingForEditor configuration is not set to false, we show
> a hint telling that we are waiting for user's editor to close the file
> when we launch an editor and wait for it to return control back to us.
> We give the message on an incomplete line, expecting that we can go back
> to the line and clear the message when the editor returns.
> 
> However, it is possible that the editor exits with an error status, in
> which case we show an error message and then return to our caller.  In
> such a case, the error message is given where the terminal cursor
> happens to be, which is most likely after the "we are waiting for your
> editor" message on the same line.

As I've said before I'm not sure how likely that is as I think the editor will probably have printed a message if there was an error. Assuming the message from the editor ends with a newline the proposed change wont do any harm so I don't object to it.

Best Wishes
Phillip
Show 33 quoted lines
> Clear the line before showing the error.
> 
> While we're here, make the error message follow our CodingGuideLines.
> 
> Signed-off-by: Rubén Justo <rjusto@gmail.com>
> ---
>   editor.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/editor.c b/editor.c
> index b67b802ddf..d1ba2d7c34 100644
> --- a/editor.c
> +++ b/editor.c
> @@ -104,16 +104,15 @@ static int launch_specified_editor(const char *editor, const char *path,
>   		sigchain_pop(SIGQUIT);
>   		if (sig == SIGINT || sig == SIGQUIT)
>   			raise(sig);
> -		if (ret)
> -			return error("There was a problem with the editor '%s'.",
> -					editor);
> -
>   		if (print_waiting_for_editor && !is_terminal_dumb())
>   			/*
>   			 * Erase the entire line to avoid wasting the
>   			 * vertical space.
>   			 */
>   			term_clear_line();
> +		if (ret)
> +			return error("there was a problem with the editor '%s'",
> +					editor);
>   	}
>   
>   	if (!buffer)
Previous: Rubén JustoNext: Rubén Justo
Message 22 of 26 in “launch_editor: waiting message on error”
  1. launch_editor: waiting message on errorRubén Justo, Apr 8, 2024
  2. launch_editor: waiting message on errorRubén Justo, Apr 8, 2024
  3. launch_editor: waiting message on errorRubén Justo, Apr 8, 2024
  4. Junio C HamanoApr 9, 2024
  5. Rubén JustoApr 9, 2024
  6. Junio C HamanoApr 10, 2024
  7. Rubén JustoApr 11, 2024
  8. Junio C HamanoApr 12, 2024
  9. Rubén JustoApr 12, 2024
  10. Junio C HamanoApr 12, 2024
  11. Rubén JustoApr 12, 2024
  12. 0/2 launch_editor: waiting messageRubén Justo, Apr 12, 2024
  13. 1/2 launch_editor: waiting for editor messageRubén Justo, Apr 12, 2024
  14. rsbecker@nexbridge.comApr 12, 2024
  15. Rubén JustoApr 12, 2024
  16. rsbecker@nexbridge.comApr 12, 2024
  17. Phillip WoodApr 13, 2024
  18. 2/2 launch_editor: waiting message on errorRubén Justo, Apr 12, 2024
  19. Phillip WoodApr 13, 2024
  20. Rubén JustoApr 14, 2024
  21. launch_editor: waiting message on errorRubén Justo, Apr 14, 2024
  22. Phillip WoodApr 15, 2024
  23. Rubén JustoApr 15, 2024
  24. Junio C HamanoApr 15, 2024
  25. Rubén JustoApr 15, 2024
  26. Junio C HamanoApr 15, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.