updated for version 7.0g
diff --git a/src/getchar.c b/src/getchar.c
index 3b9d420..88e724f 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -4335,11 +4335,26 @@
     char_u	*res;
     char_u	*p;
     char_u	*save_cmd;
+    pos_T	save_cursor;
 
     save_cmd = save_cmdline_alloc();
     if (save_cmd == NULL)
 	return NULL;
+
+    /* Forbid changing text or using ":normal" to avoid most of the bad side
+     * effects.  Also restore the cursor position. */
+    ++textlock;
+#ifdef FEAT_EX_EXTRA
+    ++ex_normal_lock;
+#endif
+    save_cursor = curwin->w_cursor;
     p = eval_to_string(str, NULL, FALSE);
+    --textlock;
+#ifdef FEAT_EX_EXTRA
+    --ex_normal_lock;
+#endif
+    curwin->w_cursor = save_cursor;
+
     restore_cmdline_alloc(save_cmd);
     if (p == NULL)
 	return NULL;