Mercurial > vim
comparison src/edit.c @ 14037:afce2005fdc8 v8.1.0036
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
commit https://github.com/vim/vim/commit/891e1fd894720d0b99a9daefa41e8181844f819a
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 6 18:02:39 2018 +0200
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 06 Jun 2018 18:15:05 +0200 |
parents | bccd66fa00c1 |
children | e182079c3374 |
comparison
equal
deleted
inserted
replaced
14036:6f08870865fb | 14037:afce2005fdc8 |
---|---|
1409 } | 1409 } |
1410 #endif | 1410 #endif |
1411 #ifdef FEAT_JOB_CHANNEL | 1411 #ifdef FEAT_JOB_CHANNEL |
1412 if (bt_prompt(curbuf)) | 1412 if (bt_prompt(curbuf)) |
1413 { | 1413 { |
1414 buf_T *buf = curbuf; | |
1415 | |
1416 invoke_prompt_callback(); | 1414 invoke_prompt_callback(); |
1417 if (curbuf != buf) | 1415 if (!bt_prompt(curbuf)) |
1418 // buffer changed, get out of Insert mode | 1416 // buffer changed to a non-prompt buffer, get out of |
1417 // Insert mode | |
1419 goto doESCkey; | 1418 goto doESCkey; |
1420 break; | 1419 break; |
1421 } | 1420 } |
1422 #endif | 1421 #endif |
1423 if (ins_eol(c) == FAIL && !p_im) | 1422 if (ins_eol(c) == FAIL && !p_im) |
1904 | 1903 |
1905 if (cmdchar_todo == 'A') | 1904 if (cmdchar_todo == 'A') |
1906 coladvance((colnr_T)MAXCOL); | 1905 coladvance((colnr_T)MAXCOL); |
1907 if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt)) | 1906 if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt)) |
1908 curwin->w_cursor.col = STRLEN(prompt); | 1907 curwin->w_cursor.col = STRLEN(prompt); |
1908 /* Make sure the cursor is in a valid position. */ | |
1909 check_cursor(); | |
1909 } | 1910 } |
1910 | 1911 |
1911 /* | 1912 /* |
1912 * Return TRUE if the cursor is in the editable position of the prompt line. | 1913 * Return TRUE if the cursor is in the editable position of the prompt line. |
1913 */ | 1914 */ |
9465 */ | 9466 */ |
9466 AppendCharToRedobuff(c); | 9467 AppendCharToRedobuff(c); |
9467 | 9468 |
9468 /* If deleted before the insertion point, adjust it */ | 9469 /* If deleted before the insertion point, adjust it */ |
9469 if (curwin->w_cursor.lnum == Insstart_orig.lnum | 9470 if (curwin->w_cursor.lnum == Insstart_orig.lnum |
9470 && curwin->w_cursor.col < Insstart_orig.col) | 9471 && curwin->w_cursor.col < Insstart_orig.col) |
9471 Insstart_orig.col = curwin->w_cursor.col; | 9472 Insstart_orig.col = curwin->w_cursor.col; |
9472 | 9473 |
9473 /* vi behaviour: the cursor moves backward but the character that | 9474 /* vi behaviour: the cursor moves backward but the character that |
9474 * was there remains visible | 9475 * was there remains visible |
9475 * Vim behaviour: the cursor moves backward and the character that | 9476 * Vim behaviour: the cursor moves backward and the character that |
9515 { | 9516 { |
9516 /* Mouse took us to another window. We need to go back to the | 9517 /* Mouse took us to another window. We need to go back to the |
9517 * previous one to stop insert there properly. */ | 9518 * previous one to stop insert there properly. */ |
9518 curwin = old_curwin; | 9519 curwin = old_curwin; |
9519 curbuf = curwin->w_buffer; | 9520 curbuf = curwin->w_buffer; |
9521 #ifdef FEAT_JOB_CHANNEL | |
9522 if (bt_prompt(curbuf)) | |
9523 // Restart Insert mode when re-entering the prompt buffer. | |
9524 curbuf->b_prompt_insert = 'A'; | |
9525 #endif | |
9520 } | 9526 } |
9521 start_arrow(curwin == old_curwin ? &tpos : NULL); | 9527 start_arrow(curwin == old_curwin ? &tpos : NULL); |
9522 if (curwin != new_curwin && win_valid(new_curwin)) | 9528 if (curwin != new_curwin && win_valid(new_curwin)) |
9523 { | 9529 { |
9524 curwin = new_curwin; | 9530 curwin = new_curwin; |