diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-06-06 09:11:12 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-06-06 09:11:12 +0200 |
commit | 6d41c78e353b630bc1a72cbff9160311d2a81e8c (patch) | |
tree | 4ed89d974b7ce1e69ae848bfea2802605c748453 /src/edit.c | |
parent | adb8fbec4f4059d214fe6acf2485ffd35e803450 (diff) |
patch 8.1.0035: not easy to switch between prompt buffer and other windowsv8.1.0035
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.
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/edit.c b/src/edit.c index 1b79eccac9..76cbfce549 100644 --- 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)) |