aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-10-03 13:57:01 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2021-12-07 11:34:24 +0000
commit28134f4e78819c2bbf0344326b9d44f21eb0d736 (patch)
treef83a2f888368a0302203e04ae09bdbf51c779e6c /src/nvim/edit.c
parentafaad8b54ebd2ad4ba2145f4069f5017cace3c8f (diff)
downloadrneovim-28134f4e78819c2bbf0344326b9d44f21eb0d736.tar.gz
rneovim-28134f4e78819c2bbf0344326b9d44f21eb0d736.tar.bz2
rneovim-28134f4e78819c2bbf0344326b9d44f21eb0d736.zip
vim-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. https://github.com/vim/vim/commit/6d41c78e353b630bc1a72cbff9160311d2a81e8c Cherry-pick channel.txt change from: https://github.com/vim/vim/commit/d2f3a8b8787333abf2300d38836b196955f10c00 b_prompt_insert was already ported.
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index fe69da7fcb..16601d327d 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -655,10 +655,17 @@ static int insert_check(VimState *state)
static int insert_execute(VimState *state, int key)
{
+ InsertState *const s = (InsertState *)state;
+ if (stop_insert_mode) {
+ // Insert mode ended, possibly from a callback.
+ s->count = 0;
+ s->nomove = true;
+ return 0;
+ }
+
if (key == K_IGNORE || key == K_NOP) {
return -1; // get another key
}
- InsertState *s = (InsertState *)state;
s->c = key;
// Don't want K_EVENT with cursorhold for the second key, e.g., after CTRL-V.
@@ -984,6 +991,15 @@ static int insert_handle_key(InsertState *s)
break;
case Ctrl_W: // delete word before the cursor
+ 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';
+ s->nomove = true;
+ s->count = 0;
+ return 0;
+ }
s->did_backspace = ins_bs(s->c, BACKSPACE_WORD, &s->inserted_space);
auto_format(false, true);
break;
@@ -1653,6 +1669,17 @@ static void init_prompt(int cmdchar_todo)
coladvance(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 != (colnr_T)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(MAXCOL);
}