vim-patch:7.4.1076

Problem:    CTRL-A does not work well in right-left mode.
Solution:   Remove reversing the line, add a test. (Hirohito Higashi)

6a3c8aff04
This commit is contained in:
watiko
2016-01-15 17:51:56 +09:00
parent 63560c9c89
commit 594e3a64de
3 changed files with 21 additions and 22 deletions

View File

@@ -4181,23 +4181,6 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, int i
bdp->textstart = pstart; bdp->textstart = pstart;
} }
static void reverse_line(char_u *s)
{
int i, j;
char_u c;
if ((i = (int)STRLEN(s) - 1) <= 0)
return;
curwin->w_cursor.col = i - curwin->w_cursor.col;
for (j = 0; j < i; j++, i--) {
c = s[i]; s[i] = s[j]; s[j] = c;
}
}
# define RLADDSUBFIX(ptr) if (curwin->w_p_rl) reverse_line(ptr);
/// Add or subtract from a number in a line. /// Add or subtract from a number in a line.
/// ///
/// @param command CTRL-A for add, CTRL-X for subtract /// @param command CTRL-A for add, CTRL-X for subtract
@@ -4249,7 +4232,6 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
} }
ptr = ml_get(VIsual.lnum); ptr = ml_get(VIsual.lnum);
RLADDSUBFIX(ptr);
if (VIsual_mode == 'V') { if (VIsual_mode == 'V') {
VIsual.col = 0; VIsual.col = 0;
curwin->w_cursor.col = STRLEN(ptr); curwin->w_cursor.col = STRLEN(ptr);
@@ -4278,7 +4260,6 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
lnume = curwin->w_cursor.lnum; lnume = curwin->w_cursor.lnum;
} else { } else {
ptr = get_cursor_line_ptr(); ptr = get_cursor_line_ptr();
RLADDSUBFIX(ptr);
if (dobin) { if (dobin) {
while (col > 0 && ascii_isbdigit(ptr[col])) { while (col > 0 && ascii_isbdigit(ptr[col])) {
@@ -4345,7 +4326,6 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
t = curwin->w_cursor; t = curwin->w_cursor;
curwin->w_cursor.lnum = i; curwin->w_cursor.lnum = i;
ptr = get_cursor_line_ptr(); ptr = get_cursor_line_ptr();
RLADDSUBFIX(ptr);
if ((int)STRLEN(ptr) <= col) { if ((int)STRLEN(ptr) <= col) {
// try again on next line // try again on next line
continue; continue;
@@ -4601,8 +4581,6 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
} }
Prenum1 += offset; Prenum1 += offset;
curwin->w_set_curswant = true; curwin->w_set_curswant = true;
ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, true);
RLADDSUBFIX(ptr);
} }
if (visual) { if (visual) {
// cursor at the top of the selection // cursor at the top of the selection

View File

@@ -558,4 +558,21 @@ func Test_visual_increment_26()
call assert_equal([0, 1, 1, 0], getpos('.')) call assert_equal([0, 1, 1, 0], getpos('.'))
endfunc endfunc
" 27) increment with 'rightreft', if supported
func Test_visual_increment_27()
if exists('+rightleft')
set rightleft
call setline(1, ["1234 56"])
exec "norm! $\<C-A>"
call assert_equal(["1234 57"], getline(1, '$'))
call assert_equal([0, 1, 7, 0], getpos('.'))
exec "norm! \<C-A>"
call assert_equal(["1234 58"], getline(1, '$'))
call assert_equal([0, 1, 7, 0], getpos('.'))
set norightleft
endif
endfunc
" vim: tabstop=2 shiftwidth=2 expandtab " vim: tabstop=2 shiftwidth=2 expandtab

View File

@@ -79,6 +79,10 @@ static int included_patches[] = {
1076,
// 1075,
// 1074,
// 1073,
1072, 1072,
// 1071, // 1071,
// 1070, // 1070,