Created
July 27, 2017 14:02
-
-
Save ichizok/0f5559a771ae40c15616e20cd3515d2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/eval.c b/src/eval.c | |
index 401171c9b..4cb32893f 100644 | |
--- a/src/eval.c | |
+++ b/src/eval.c | |
@@ -5329,6 +5329,10 @@ garbage_collect(int testing) | |
abort = abort || set_ref_in_quickfix(copyID); | |
#endif | |
+#ifdef FEAT_TERMINAL | |
+ abort = abort || set_ref_in_term(copyID); | |
+#endif | |
+ | |
if (!abort) | |
{ | |
/* | |
diff --git a/src/proto/terminal.pro b/src/proto/terminal.pro | |
index d7d153850..ac0beb51d 100644 | |
--- a/src/proto/terminal.pro | |
+++ b/src/proto/terminal.pro | |
@@ -6,4 +6,5 @@ void terminal_loop(void); | |
void term_job_ended(job_T *job); | |
void term_update_window(win_T *wp); | |
char_u *term_get_status_text(term_T *term); | |
+int set_ref_in_term(int copyID); | |
/* vim: set ft=c : */ | |
diff --git a/src/terminal.c b/src/terminal.c | |
index 0532d01f9..3874564d4 100644 | |
--- a/src/terminal.c | |
+++ b/src/terminal.c | |
@@ -1241,6 +1241,7 @@ term_and_job_init(term_T *term, int rows, int cols, char_u *cmd) | |
job->jv_proc_info.dwProcessId = GetProcessId(child_process_handle); | |
job->jv_job_object = jo; | |
job->jv_status = JOB_STARTED; | |
+ ++job->jv_refcount; | |
term->tl_job = job; | |
return OK; | |
@@ -1320,6 +1321,8 @@ term_and_job_init(term_T *term, int rows, int cols, char_u *cmd) | |
argvars[0].vval.v_string = cmd; | |
setup_job_options(&opt, rows, cols); | |
term->tl_job = job_start(argvars, &opt); | |
+ if (term->tl_job != NULL) | |
+ ++term->tl_job->jv_refcount; | |
return term->tl_job != NULL | |
&& term->tl_job->jv_channel != NULL | |
@@ -1359,6 +1362,28 @@ term_report_winsize(term_T *term, int rows, int cols) | |
} | |
} | |
+/* | |
+ * Mark references in jobs of terminals. | |
+ */ | |
+ int | |
+set_ref_in_term(int copyID) | |
+{ | |
+ int abort = FALSE; | |
+ term_T *term; | |
+ typval_T tv; | |
+ | |
+ for (term = first_term; term != NULL; term = term->tl_next) | |
+ { | |
+ if (term->tl_job != NULL) | |
+ { | |
+ tv.v_type = VAR_JOB; | |
+ tv.vval.v_job = term->tl_job; | |
+ abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); | |
+ } | |
+ } | |
+ return abort; | |
+} | |
+ | |
# endif | |
#endif /* FEAT_TERMINAL */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment