Re: [PATCH v3] launch_editor(): indicate that Git waits for user input
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Nov 27, 2017, 18:36 UTC
- Message-ID
- <CAPig+cSStSbckFi5K33z0WZThjNZC5Eb1Fb+ikrd5ZajM6mV3Q@mail.gmail.com>
- In-Reply-To
- <20171127134716.69471-1-lars.schneider@autodesk.com>
On Mon, Nov 27, 2017 at 8:47 AM, <lars.schneider@autodesk.com> wrote:
Show 29 quoted lines
> When a graphical GIT_EDITOR is spawned by a Git command that opens
> and waits for user input (e.g. "git rebase -i"), then the editor window
> might be obscured by other windows. The user may be left staring at the
> original Git terminal window without even realizing that s/he needs to
> interact with another window before Git can proceed. To this user Git
> appears hanging.
>
> Show a message in the original terminal and get rid of it when the
> editor returns.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
> ---
> diff --git a/editor.c b/editor.c
> @@ -40,6 +40,35 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
> + static const char *close_notice = NULL;
> +
> + if (isatty(2) && !close_notice) {
> + char *term = getenv("TERM");
> +
> + if (term && strcmp(term, "dumb"))
> + /*
> + * go back to the beginning and erase the
> + * entire line if the terminal is capable
> + * to do so, to avoid wasting the vertical
> + * space.
> + */
> + close_notice = "\r\033[K";
> + else if (term && strstr(term, "emacsclient"))You need to check 'editor' here, not 'term', and you should do it before the "not dumb" terminal check, otherwise you'll never get this far.
Show 10 quoted lines
> + /*
> + * `emacsclient` (or `emacsclientw` on Windows) already prints
> + * ("Waiting for Emacs...") if a file is opened for editing.
> + * Therefore, we don't need to print the editor launch info.
> + */
> + ;
> + else
> + /* otherwise, complete and waste the line */
> + close_notice = _("done.\n");
> + }