mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 23:08:16 +00:00
vim-patch:7.4.186
Problem: Insert in Visual mode sometimes gives incorrect results. (Dominique Pelle) Solution: Remember the original insert start position. (Christian Brabandt, Dominique Pelle) https://code.google.com/p/vim/source/detail?r=4d12112c5efae071aecbeed1a7196f18950457b3
This commit is contained in:

committed by
Thiago de Arruda

parent
ac62041138
commit
d11f805150
@@ -492,6 +492,7 @@ struct file_buffer {
|
|||||||
* start and end of an operator, also used for '[ and ']
|
* start and end of an operator, also used for '[ and ']
|
||||||
*/
|
*/
|
||||||
pos_T b_op_start;
|
pos_T b_op_start;
|
||||||
|
pos_T b_op_start_orig; // used for Insstart_orig
|
||||||
pos_T b_op_end;
|
pos_T b_op_end;
|
||||||
|
|
||||||
int b_marks_read; /* Have we read viminfo marks yet? */
|
int b_marks_read; /* Have we read viminfo marks yet? */
|
||||||
|
10
src/edit.c
10
src/edit.c
@@ -284,6 +284,7 @@ static char_u *do_insert_char_pre(int c);
|
|||||||
|
|
||||||
static colnr_T Insstart_textlen; /* length of line when insert started */
|
static colnr_T Insstart_textlen; /* length of line when insert started */
|
||||||
static colnr_T Insstart_blank_vcol; /* vcol for first inserted blank */
|
static colnr_T Insstart_blank_vcol; /* vcol for first inserted blank */
|
||||||
|
static bool update_Insstart_orig = true; /* set Insstart_orig to Insstart */
|
||||||
|
|
||||||
static char_u *last_insert = NULL; /* the text of the previous insert,
|
static char_u *last_insert = NULL; /* the text of the previous insert,
|
||||||
K_SPECIAL and CSI are escaped */
|
K_SPECIAL and CSI are escaped */
|
||||||
@@ -353,6 +354,9 @@ edit (
|
|||||||
* error message */
|
* error message */
|
||||||
check_for_delay(TRUE);
|
check_for_delay(TRUE);
|
||||||
|
|
||||||
|
// set Insstart_orig to Insstart
|
||||||
|
update_Insstart_orig = true;
|
||||||
|
|
||||||
#ifdef HAVE_SANDBOX
|
#ifdef HAVE_SANDBOX
|
||||||
/* Don't allow inserting in the sandbox. */
|
/* Don't allow inserting in the sandbox. */
|
||||||
if (sandbox != 0) {
|
if (sandbox != 0) {
|
||||||
@@ -582,6 +586,10 @@ edit (
|
|||||||
if (arrow_used) /* don't repeat insert when arrow key used */
|
if (arrow_used) /* don't repeat insert when arrow key used */
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
|
if (update_Insstart_orig) {
|
||||||
|
Insstart_orig = Insstart;
|
||||||
|
}
|
||||||
|
|
||||||
if (stop_insert_mode) {
|
if (stop_insert_mode) {
|
||||||
/* ":stopinsert" used or 'insertmode' reset */
|
/* ":stopinsert" used or 'insertmode' reset */
|
||||||
count = 0;
|
count = 0;
|
||||||
@@ -5860,6 +5868,7 @@ stop_insert (
|
|||||||
* now in a different buffer. */
|
* now in a different buffer. */
|
||||||
if (end_insert_pos != NULL) {
|
if (end_insert_pos != NULL) {
|
||||||
curbuf->b_op_start = Insstart;
|
curbuf->b_op_start = Insstart;
|
||||||
|
curbuf->b_op_start_orig = Insstart_orig;
|
||||||
curbuf->b_op_end = *end_insert_pos;
|
curbuf->b_op_end = *end_insert_pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6944,6 +6953,7 @@ static void ins_ctrl_g(void)
|
|||||||
|
|
||||||
/* Need to reset Insstart, esp. because a BS that joins
|
/* Need to reset Insstart, esp. because a BS that joins
|
||||||
* a line to the previous one must save for undo. */
|
* a line to the previous one must save for undo. */
|
||||||
|
update_Insstart_orig = false;
|
||||||
Insstart = curwin->w_cursor;
|
Insstart = curwin->w_cursor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -585,6 +585,12 @@ EXTERN pos_T saved_cursor /* w_cursor before formatting text. */
|
|||||||
*/
|
*/
|
||||||
EXTERN pos_T Insstart; /* This is where the latest
|
EXTERN pos_T Insstart; /* This is where the latest
|
||||||
* insert/append mode started. */
|
* insert/append mode started. */
|
||||||
|
|
||||||
|
// This is where the latest insert/append mode started. In contrast to
|
||||||
|
// Insstart, this won't be reset by certain keys and is needed for
|
||||||
|
// op_insert(), to detect correctly where inserting by the user started.
|
||||||
|
EXTERN pos_T Insstart_orig;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stuff for VREPLACE mode.
|
* Stuff for VREPLACE mode.
|
||||||
*/
|
*/
|
||||||
|
10
src/ops.c
10
src/ops.c
@@ -2142,16 +2142,16 @@ void op_insert(oparg_T *oap, long count1)
|
|||||||
|
|
||||||
/* The user may have moved the cursor before inserting something, try
|
/* The user may have moved the cursor before inserting something, try
|
||||||
* to adjust the block for that. */
|
* to adjust the block for that. */
|
||||||
if (oap->start.lnum == curbuf->b_op_start.lnum && !bd.is_MAX) {
|
if (oap->start.lnum == curbuf->b_op_start_orig.lnum && !bd.is_MAX) {
|
||||||
if (oap->op_type == OP_INSERT
|
if (oap->op_type == OP_INSERT
|
||||||
&& oap->start.col != curbuf->b_op_start.col) {
|
&& oap->start.col != curbuf->b_op_start_orig.col) {
|
||||||
oap->start.col = curbuf->b_op_start.col;
|
oap->start.col = curbuf->b_op_start_orig.col;
|
||||||
pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
|
pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
|
||||||
- oap->start_vcol;
|
- oap->start_vcol;
|
||||||
oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
|
oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
|
||||||
} else if (oap->op_type == OP_APPEND
|
} else if (oap->op_type == OP_APPEND
|
||||||
&& oap->end.col >= curbuf->b_op_start.col) {
|
&& oap->end.col >= curbuf->b_op_start_orig.col) {
|
||||||
oap->start.col = curbuf->b_op_start.col;
|
oap->start.col = curbuf->b_op_start_orig.col;
|
||||||
/* reset pre_textlen to the value of OP_INSERT */
|
/* reset pre_textlen to the value of OP_INSERT */
|
||||||
pre_textlen += bd.textlen;
|
pre_textlen += bd.textlen;
|
||||||
pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
|
pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
|
||||||
|
@@ -202,6 +202,8 @@ static char *(features[]) = {
|
|||||||
|
|
||||||
static int included_patches[] = {
|
static int included_patches[] = {
|
||||||
// Add new patch number below this line
|
// Add new patch number below this line
|
||||||
|
186,
|
||||||
|
//185,
|
||||||
184,
|
184,
|
||||||
//183,
|
//183,
|
||||||
//182,
|
//182,
|
||||||
|
Reference in New Issue
Block a user