diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-06-06 18:02:39 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-06-06 18:02:39 +0200 |
commit | 891e1fd894720d0b99a9daefa41e8181844f819a (patch) | |
tree | ea5da71e753bf0022cc832a1397ea262d8d8a64c /src/edit.c | |
parent | 6d41c78e353b630bc1a72cbff9160311d2a81e8c (diff) |
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mousev8.1.0036
Problem: Not restoring Insert mode if leaving a prompt buffer by using a
mouse click.
Solution: Set b_prompt_insert appropriately. Also correct cursor position
when moving cursor to last line.
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/edit.c b/src/edit.c index 76cbfce549..7c7fadd10a 100644 --- a/src/edit.c +++ b/src/edit.c @@ -1411,11 +1411,10 @@ doESCkey: #ifdef FEAT_JOB_CHANNEL if (bt_prompt(curbuf)) { - buf_T *buf = curbuf; - invoke_prompt_callback(); - if (curbuf != buf) - // buffer changed, get out of Insert mode + if (!bt_prompt(curbuf)) + // buffer changed to a non-prompt buffer, get out of + // Insert mode goto doESCkey; break; } @@ -1906,6 +1905,8 @@ init_prompt(int cmdchar_todo) coladvance((colnr_T)MAXCOL); if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt)) curwin->w_cursor.col = STRLEN(prompt); + /* Make sure the cursor is in a valid position. */ + check_cursor(); } /* @@ -9467,7 +9468,7 @@ ins_bs( /* If deleted before the insertion point, adjust it */ if (curwin->w_cursor.lnum == Insstart_orig.lnum - && curwin->w_cursor.col < Insstart_orig.col) + && curwin->w_cursor.col < Insstart_orig.col) Insstart_orig.col = curwin->w_cursor.col; /* vi behaviour: the cursor moves backward but the character that @@ -9517,6 +9518,11 @@ ins_mouse(int c) * previous one to stop insert there properly. */ curwin = old_curwin; curbuf = curwin->w_buffer; +#ifdef FEAT_JOB_CHANNEL + if (bt_prompt(curbuf)) + // Restart Insert mode when re-entering the prompt buffer. + curbuf->b_prompt_insert = 'A'; +#endif } start_arrow(curwin == old_curwin ? &tpos : NULL); if (curwin != new_curwin && win_valid(new_curwin)) |