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.
*/
if (!nomove
&& (curwin->w_cursor.col != 0
|| curwin->w_cursor.coladd > 0
)
&& (restart_edit == NUL
|| (gchar_cursor() == NUL
&& !VIsual_active
))
&& (curwin->w_cursor.col != 0 || curwin->w_cursor.coladd > 0)
&& (restart_edit == NUL || (gchar_cursor() == NUL && !VIsual_active))
&& !revins_on) {
if (curwin->w_cursor.coladd > 0 || get_ve_flags() == VE_ALL) {
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) {
case OP_LSHIFT:
case OP_RSHIFT:
op_shift(oap, true,
oap->is_VIsual ? (int)cap->count1 :
1);
op_shift(oap, true, oap->is_VIsual ? (int)cap->count1 : 1);
auto_format(false, true);
break;

View File

@@ -514,7 +514,7 @@ void last_pat_prog(regmmatch_T *regmatch)
--emsg_off;
}
/// lowest level search function.
/// Lowest level search function.
/// Search for 'count'th occurrence of pattern "pat" in direction "dir".
/// 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) {
col_start -= n; // uneven number of escape chars, skip it
} else if (line[col_start] ==
quotechar) {
} else if (line[col_start] == quotechar) {
break;
}
}
@@ -4115,8 +4114,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
col_end = curwin->w_cursor.col;
}
}
} else if (line[col_start] == quotechar
|| !vis_empty) {
} else if (line[col_start] == quotechar || !vis_empty) {
int first_col = col_start;
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 ".
// For v2i" include the quotes.
if (!include && count < 2
&& (vis_empty || !inside_quotes)) {
++col_start;
if (!include && count < 2 && (vis_empty || !inside_quotes)) {
col_start++;
}
curwin->w_cursor.col = col_start;
if (VIsual_active) {

View File

@@ -1422,9 +1422,16 @@ func Test_normal27_bracket()
call assert_equal(5, line('.'))
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
norm! $]'
norm! 5|]'
call assert_equal(' 21 b', getline('.'))
call assert_equal(21, line('.'))
call assert_equal(3, col('.'))
@@ -1441,12 +1448,40 @@ func Test_normal27_bracket()
call assert_equal(20, line('.'))
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
bw!
endfunc
" Test for ( and ) sentence movements
func Test_normal28_parenthesis()
" basic testing for ( and )
new
call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])