patch 9.0.1443: ending Insert mode when accessing a hidden prompt buffer

Problem:    Ending Insert mode when accessing a hidden prompt buffer.
Solution:   Don't stop Insert mode when it was active before. (closes #12237)
diff --git a/src/testdir/test_prompt_buffer.vim b/src/testdir/test_prompt_buffer.vim
index 28e0d76..b81309c 100644
--- a/src/testdir/test_prompt_buffer.vim
+++ b/src/testdir/test_prompt_buffer.vim
@@ -270,6 +270,7 @@
 
       func DoAppend()
         call appendbufline('prompt', '$', 'Test')
+        return ''
       endfunc
   END
   call writefile(script, 'XpromptBuffer', 'D')
@@ -282,11 +283,21 @@
 
   call term_sendkeys(buf, "exit\<CR>")
   call TermWait(buf)
+  call assert_notmatch('-- INSERT --', term_getline(buf, 10))
 
   call term_sendkeys(buf, ":call DoAppend()\<CR>")
   call TermWait(buf)
   call assert_notmatch('-- INSERT --', term_getline(buf, 10))
 
+  call term_sendkeys(buf, "i")
+  call TermWait(buf)
+  call assert_match('-- INSERT --', term_getline(buf, 10))
+
+  call term_sendkeys(buf, "\<C-R>=DoAppend()\<CR>")
+  call TermWait(buf)
+  call assert_match('-- INSERT --', term_getline(buf, 10))
+
+  call term_sendkeys(buf, "\<Esc>")
   call StopVimInTerminal(buf)
 endfunc