Merge pull request #19247 from zeertzjq/vim-8.2.4165

vim-patch:7.4.212,8.2.{4165,4221}: some functions in normal.c are too long
This commit is contained in:
zeertzjq
2022-07-06 20:44:41 +08:00
committed by GitHub
5 changed files with 592 additions and 485 deletions

View File

@@ -7935,13 +7935,8 @@ static bool ins_esc(long *count, int cmdchar, bool nomove)
* Don't do it for CTRL-O, unless past the end of the line. * Don't do it for CTRL-O, unless past the end of the line.
*/ */
if (!nomove if (!nomove
&& (curwin->w_cursor.col != 0 && (curwin->w_cursor.col != 0 || curwin->w_cursor.coladd > 0)
|| curwin->w_cursor.coladd > 0 && (restart_edit == NUL || (gchar_cursor() == NUL && !VIsual_active))
)
&& (restart_edit == NUL
|| (gchar_cursor() == NUL
&& !VIsual_active
))
&& !revins_on) { && !revins_on) {
if (curwin->w_cursor.coladd > 0 || get_ve_flags() == VE_ALL) { if (curwin->w_cursor.coladd > 0 || get_ve_flags() == VE_ALL) {
oneleft(); oneleft();

File diff suppressed because it is too large Load Diff

View File

@@ -6627,9 +6627,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
switch (oap->op_type) { switch (oap->op_type) {
case OP_LSHIFT: case OP_LSHIFT:
case OP_RSHIFT: case OP_RSHIFT:
op_shift(oap, true, op_shift(oap, true, oap->is_VIsual ? (int)cap->count1 : 1);
oap->is_VIsual ? (int)cap->count1 :
1);
auto_format(false, true); auto_format(false, true);
break; break;

View File

@@ -514,7 +514,7 @@ void last_pat_prog(regmmatch_T *regmatch)
--emsg_off; --emsg_off;
} }
/// lowest level search function. /// Lowest level search function.
/// Search for 'count'th occurrence of pattern "pat" in direction "dir". /// Search for 'count'th occurrence of pattern "pat" in direction "dir".
/// Start at position "pos" and return the found position in "pos". /// Start at position "pos" and return the found position in "pos".
/// ///
@@ -3991,8 +3991,7 @@ static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *e
} }
if (n & 1) { if (n & 1) {
col_start -= n; // uneven number of escape chars, skip it col_start -= n; // uneven number of escape chars, skip it
} else if (line[col_start] == } else if (line[col_start] == quotechar) {
quotechar) {
break; break;
} }
} }
@@ -4115,8 +4114,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
col_end = curwin->w_cursor.col; col_end = curwin->w_cursor.col;
} }
} }
} else if (line[col_start] == quotechar } else if (line[col_start] == quotechar || !vis_empty) {
|| !vis_empty) {
int first_col = col_start; int first_col = col_start;
if (!vis_empty) { if (!vis_empty) {
@@ -4185,9 +4183,8 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
// Set start position. After vi" another i" must include the ". // Set start position. After vi" another i" must include the ".
// For v2i" include the quotes. // For v2i" include the quotes.
if (!include && count < 2 if (!include && count < 2 && (vis_empty || !inside_quotes)) {
&& (vis_empty || !inside_quotes)) { col_start++;
++col_start;
} }
curwin->w_cursor.col = col_start; curwin->w_cursor.col = col_start;
if (VIsual_active) { if (VIsual_active) {

View File

@@ -1422,9 +1422,16 @@ func Test_normal27_bracket()
call assert_equal(5, line('.')) call assert_equal(5, line('.'))
call assert_equal(3, col('.')) call assert_equal(3, col('.'))
" No mark after line 21, cursor moves to first non blank on current line " No mark before line 1, cursor moves to first non-blank on current line
1
norm! 5|['
call assert_equal(' 1 b', getline('.'))
call assert_equal(1, line('.'))
call assert_equal(3, col('.'))
" No mark after line 21, cursor moves to first non-blank on current line
21 21
norm! $]' norm! 5|]'
call assert_equal(' 21 b', getline('.')) call assert_equal(' 21 b', getline('.'))
call assert_equal(21, line('.')) call assert_equal(21, line('.'))
call assert_equal(3, col('.')) call assert_equal(3, col('.'))
@@ -1441,12 +1448,40 @@ func Test_normal27_bracket()
call assert_equal(20, line('.')) call assert_equal(20, line('.'))
call assert_equal(8, col('.')) call assert_equal(8, col('.'))
" No mark before line 1, cursor does not move
1
norm! 5|[`
call assert_equal(' 1 b', getline('.'))
call assert_equal(1, line('.'))
call assert_equal(5, col('.'))
" No mark after line 21, cursor does not move
21
norm! 5|]`
call assert_equal(' 21 b', getline('.'))
call assert_equal(21, line('.'))
call assert_equal(5, col('.'))
" Count too large for [`
" cursor moves to first lowercase mark
norm! 99[`
call assert_equal(' 1 b', getline('.'))
call assert_equal(1, line('.'))
call assert_equal(7, col('.'))
" Count too large for ]`
" cursor moves to last lowercase mark
norm! 99]`
call assert_equal(' 20 b', getline('.'))
call assert_equal(20, line('.'))
call assert_equal(8, col('.'))
" clean up " clean up
bw! bw!
endfunc endfunc
" Test for ( and ) sentence movements
func Test_normal28_parenthesis() func Test_normal28_parenthesis()
" basic testing for ( and )
new new
call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here']) call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])