mirror of
https://github.com/git-for-windows/git.git
synced 2026-02-03 18:59:59 -06:00
Merge branch 'un-revert-editor-save-and-reset'
A fix for calling `vim` in Windows Terminal caused a regression and was reverted. We partially un-revert this, to get the fix again. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
commit
8e98c97bc3
8
editor.c
8
editor.c
@ -13,6 +13,7 @@
|
||||
#include "strvec.h"
|
||||
#include "run-command.h"
|
||||
#include "sigchain.h"
|
||||
#include "compat/terminal.h"
|
||||
|
||||
#ifndef DEFAULT_EDITOR
|
||||
#define DEFAULT_EDITOR "vi"
|
||||
@ -64,6 +65,7 @@ static int launch_specified_editor(const char *editor, const char *path,
|
||||
return error("Terminal is dumb, but EDITOR unset");
|
||||
|
||||
if (strcmp(editor, ":")) {
|
||||
int save_and_restore_term = !strcmp(editor, "vi") || !strcmp(editor, "vim");
|
||||
struct strbuf realpath = STRBUF_INIT;
|
||||
struct child_process p = CHILD_PROCESS_INIT;
|
||||
int ret, sig;
|
||||
@ -92,7 +94,11 @@ static int launch_specified_editor(const char *editor, const char *path,
|
||||
strvec_pushv(&p.env, (const char **)env);
|
||||
p.use_shell = 1;
|
||||
p.trace2_child_class = "editor";
|
||||
if (save_and_restore_term)
|
||||
save_and_restore_term = !save_term(1);
|
||||
if (start_command(&p) < 0) {
|
||||
if (save_and_restore_term)
|
||||
restore_term();
|
||||
strbuf_release(&realpath);
|
||||
return error("unable to start editor '%s'", editor);
|
||||
}
|
||||
@ -100,6 +106,8 @@ static int launch_specified_editor(const char *editor, const char *path,
|
||||
sigchain_push(SIGINT, SIG_IGN);
|
||||
sigchain_push(SIGQUIT, SIG_IGN);
|
||||
ret = finish_command(&p);
|
||||
if (save_and_restore_term)
|
||||
restore_term();
|
||||
strbuf_release(&realpath);
|
||||
sig = ret - 128;
|
||||
sigchain_pop(SIGINT);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user