patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Problem: Cannot handle pressing CTRL-C in a prompt buffer.
Solution: Add prompt_setinterrupt().
diff --git a/src/channel.c b/src/channel.c
index d654dc0..1363ee9 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -5856,7 +5856,7 @@
curwin->w_cursor.lnum = lnum + 1;
curwin->w_cursor.col = 0;
- if (curbuf->b_prompt_callback == NULL)
+ if (curbuf->b_prompt_callback == NULL || *curbuf->b_prompt_callback == NUL)
return;
text = ml_get(lnum);
prompt = prompt_text();
@@ -5874,4 +5874,28 @@
clear_tv(&rettv);
}
+/*
+ * Return TRUE when the interrupt callback was invoked.
+ */
+ int
+invoke_prompt_interrupt(void)
+{
+ typval_T rettv;
+ int dummy;
+ typval_T argv[1];
+
+ if (curbuf->b_prompt_interrupt == NULL
+ || *curbuf->b_prompt_interrupt == NUL)
+ return FALSE;
+ argv[0].v_type = VAR_UNKNOWN;
+
+ got_int = FALSE; // don't skip executing commands
+ call_func(curbuf->b_prompt_interrupt,
+ (int)STRLEN(curbuf->b_prompt_interrupt),
+ &rettv, 0, argv, NULL, 0L, 0L, &dummy, TRUE,
+ curbuf->b_prompt_int_partial, NULL);
+ clear_tv(&rettv);
+ return TRUE;
+}
+
#endif /* FEAT_JOB_CHANNEL */