diff src/edit.c @ 14035:bccd66fa00c1 v8.1.0035

patch 8.1.0035: not easy to switch between prompt buffer and other windows commit https://github.com/vim/vim/commit/6d41c78e353b630bc1a72cbff9160311d2a81e8c Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 6 09:11:12 2018 +0200 patch 8.1.0035: not easy to switch between prompt buffer and other windows Problem: Not easy to switch between prompt buffer and other windows. Solution: Accept CTRL-W commands in Insert mode. Start and stop Insert mode as one would expect.
author Christian Brabandt <cb@256bit.org>
date Wed, 06 Jun 2018 09:15:06 +0200
parents dc67449d648c
children afce2005fdc8
line wrap: on
line diff
--- a/src/edit.c
+++ b/src/edit.c
@@ -811,6 +811,14 @@ edit(
 	    do
 	    {
 		c = safe_vgetc();
+
+		if (stop_insert_mode)
+		{
+		    // Insert mode ended, possibly from a callback.
+		    count = 0;
+		    nomove = TRUE;
+		    goto doESCkey;
+		}
 	    } while (c == K_IGNORE || c == K_NOP);
 
 	/* Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. */
@@ -1165,6 +1173,18 @@ doESCkey:
 	    break;
 
 	case Ctrl_W:	/* delete word before the cursor */
+#ifdef FEAT_JOB_CHANNEL
+	    if (bt_prompt(curbuf) && (mod_mask & MOD_MASK_SHIFT) == 0)
+	    {
+		// In a prompt window CTRL-W is used for window commands.
+		// Use Shift-CTRL-W to delete a word.
+		stuffcharReadbuff(Ctrl_W);
+		restart_edit = 'i';
+		nomove = TRUE;
+		count = 0;
+		goto doESCkey;
+	    }
+#endif
 	    did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space);
 	    auto_format(FALSE, TRUE);
 	    break;
@@ -1869,6 +1889,19 @@ init_prompt(int cmdchar_todo)
 	coladvance((colnr_T)MAXCOL);
 	changed_bytes(curbuf->b_ml.ml_line_count, 0);
     }
+
+    // Insert always starts after the prompt, allow editing text after it.
+    if (Insstart_orig.lnum != curwin->w_cursor.lnum
+				   || Insstart_orig.col != (int)STRLEN(prompt))
+    {
+	Insstart.lnum = curwin->w_cursor.lnum;
+	Insstart.col = STRLEN(prompt);
+	Insstart_orig = Insstart;
+	Insstart_textlen = Insstart.col;
+	Insstart_blank_vcol = MAXCOL;
+	arrow_used = FALSE;
+    }
+
     if (cmdchar_todo == 'A')
 	coladvance((colnr_T)MAXCOL);
     if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt))