comparison src/ops.c @ 13620:4faf77b96432 v8.0.1682

patch 8.0.1682: auto indenting breaks inserting a block commit https://github.com/vim/vim/commit/8c87a2b1fec85e4aac33f71586ac1514536fc66b Author: Bram Moolenaar <Bram@vim.org> Date: Tue Apr 10 13:15:47 2018 +0200 patch 8.0.1682: auto indenting breaks inserting a block Problem: Auto indenting breaks inserting a block. Solution: Do not check for cursor movement if indent was changed. (Christian Brabandt, closes #2778)
author Christian Brabandt <cb@256bit.org>
date Tue, 10 Apr 2018 13:30:07 +0200
parents 87e5629fc915
children 7ed76dcf0d94
comparison
equal deleted inserted replaced
13619:41ed86454233 13620:4faf77b96432
1091 yankreg_T *old_y_previous, *old_y_current; 1091 yankreg_T *old_y_previous, *old_y_current;
1092 int retval; 1092 int retval;
1093 1093
1094 if (Recording == FALSE) /* start recording */ 1094 if (Recording == FALSE) /* start recording */
1095 { 1095 {
1096 /* registers 0-9, a-z and " are allowed */ 1096 /* registers 0-9, a-z and " are allowed */
1097 if (c < 0 || (!ASCII_ISALNUM(c) && c != '"')) 1097 if (c < 0 || (!ASCII_ISALNUM(c) && c != '"'))
1098 retval = FAIL; 1098 retval = FAIL;
1099 else 1099 else
1100 { 1100 {
1101 Recording = c; 1101 Recording = c;
2700 return; 2700 return;
2701 2701
2702 if (oap->block_mode) 2702 if (oap->block_mode)
2703 { 2703 {
2704 struct block_def bd2; 2704 struct block_def bd2;
2705 int did_indent = FALSE;
2705 2706
2706 /* If indent kicked in, the firstline might have changed 2707 /* If indent kicked in, the firstline might have changed
2707 * but only do that, if the indent actually increased. */ 2708 * but only do that, if the indent actually increased. */
2708 ind_post = (colnr_T)getwhitecols_curline(); 2709 ind_post = (colnr_T)getwhitecols_curline();
2709 if (curbuf->b_op_start.col > ind_pre && ind_post > ind_pre) 2710 if (curbuf->b_op_start.col > ind_pre && ind_post > ind_pre)
2710 { 2711 {
2711 bd.textcol += ind_post - ind_pre; 2712 bd.textcol += ind_post - ind_pre;
2712 bd.start_vcol += ind_post - ind_pre; 2713 bd.start_vcol += ind_post - ind_pre;
2714 did_indent = TRUE;
2713 } 2715 }
2714 2716
2715 /* The user may have moved the cursor before inserting something, try 2717 /* The user may have moved the cursor before inserting something, try
2716 * to adjust the block for that. */ 2718 * to adjust the block for that. But only do it, if the difference
2717 if (oap->start.lnum == curbuf->b_op_start_orig.lnum && !bd.is_MAX) 2719 * does not come from indent kicking in. */
2720 if (oap->start.lnum == curbuf->b_op_start_orig.lnum
2721 && !bd.is_MAX && !did_indent)
2718 { 2722 {
2719 if (oap->op_type == OP_INSERT 2723 if (oap->op_type == OP_INSERT
2720 && oap->start.col 2724 && oap->start.col
2721 #ifdef FEAT_VIRTUALEDIT 2725 #ifdef FEAT_VIRTUALEDIT
2722 + oap->start.coladd 2726 + oap->start.coladd