Skip to content

Commit 70ed7cb

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
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 <[email protected]>
2 parents 6cca84f + 4641773 commit 70ed7cb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: editor.c

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "strvec.h"
1414
#include "run-command.h"
1515
#include "sigchain.h"
16+
#include "compat/terminal.h"
1617

1718
#ifndef DEFAULT_EDITOR
1819
#define DEFAULT_EDITOR "vi"
@@ -64,6 +65,7 @@ static int launch_specified_editor(const char *editor, const char *path,
6465
return error("Terminal is dumb, but EDITOR unset");
6566

6667
if (strcmp(editor, ":")) {
68+
int save_and_restore_term = !strcmp(editor, "vi") || !strcmp(editor, "vim");
6769
struct strbuf realpath = STRBUF_INIT;
6870
struct child_process p = CHILD_PROCESS_INIT;
6971
int ret, sig;
@@ -92,14 +94,20 @@ static int launch_specified_editor(const char *editor, const char *path,
9294
strvec_pushv(&p.env, (const char **)env);
9395
p.use_shell = 1;
9496
p.trace2_child_class = "editor";
97+
if (save_and_restore_term)
98+
save_and_restore_term = !save_term(1);
9599
if (start_command(&p) < 0) {
100+
if (save_and_restore_term)
101+
restore_term();
96102
strbuf_release(&realpath);
97103
return error("unable to start editor '%s'", editor);
98104
}
99105

100106
sigchain_push(SIGINT, SIG_IGN);
101107
sigchain_push(SIGQUIT, SIG_IGN);
102108
ret = finish_command(&p);
109+
if (save_and_restore_term)
110+
restore_term();
103111
strbuf_release(&realpath);
104112
sig = ret - 128;
105113
sigchain_pop(SIGINT);

0 commit comments

Comments
 (0)