patch 8.2.1988: still in Insert mode when opening terminal popup

Problem:    Still in Insert mode when opening terminal popup with a <Cmd>
            mapping in Insert mode.
Solution:   Exit Insert mode. (closes #7295)
diff --git a/src/edit.c b/src/edit.c
index d92a951..8c5cec3 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1033,6 +1033,11 @@
 
 	case K_COMMAND:		// <Cmd>command<CR>
 	    do_cmdline(NULL, getcmdkeycmd, NULL, 0);
+#ifdef FEAT_TERMINAL
+	    if (term_use_loop())
+		// Started a terminal that gets the input, exit Insert mode.
+		goto doESCkey;
+#endif
 	    break;
 
 	case K_CURSORHOLD:	// Didn't type something for a while.