0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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.
This commit is contained in:
Bram Moolenaar
2018-06-06 09:11:12 +02:00
parent adb8fbec4f
commit 6d41c78e35
5 changed files with 82 additions and 1 deletions

View File

@@ -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))