Hi,
2016-1-10(Sun) 4:15:14 UTC+9 Bram Moolenaar:
> Hirohito Higashi wrote:
>
> > 2016-1-8(Fri) 2:27:17 UTC+9 Bram Moolenaar:
> > > Hirohito Higashi wrote:
> > >
> > > > > > To: Bram (As a Vimboss)
> > > > > > To: Christian Brabandt (As a visual <C-A>/<C-X> first patch author)
> > > > > > To: Jason Schulz (As a support for bin 'nrformats' patch author)
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I refactored visual <C-A>/<C-X> to support vcol et al.
> > > > > > This mean is <TAB> code free!
> > > > > >
> > > > > > Contents of patch.
> > > > > > - visual <C-A>/<C-X> support vcol. (<TAB> code free)
> > > > > > - 'test_increment' convert from old style test to new style test.
> > > > > > and added some test items.
> > > > > > - Processing was allowed to separate.
> > > > > > (line loop process and add/subtract process)
> > > > > > (We have to use the existing function block_prep() to process the
> > > > > > block-wise)
> > > > > > - We removed the halfway right-to-left processing.
> > > > > > (Remove RLADDSUBFIX() macro)
> > > > > > (This is causing the actual problem)
> > > > > > $ vim -Nu NONE -c "set rightleft"
> > > > > > i123 45<Esc>
> > > > > > <C-A> " Unexpected swap the numbers of strings
> > > > > > occurred.
> > > > > >
> > > > > > Christian Brabandt and Jason Schulz and List>
> > > > > > I was wondering if you could review this patch.
> > > > > >
> > > > > > Jason Schulz>
> > > > > > Sorry to such just your patch was included.
> > > > > > I have just completed the doing has been working since last fall :-)
> > > > >
> > > > > That's a big change. Can you give an example of what didn't work
> > > > > before
> > > > > and works now?
> > > >
> > > > Please see Test_visual_increment_27() ~ Test_visual_increment_34().
> > > > Below is ather exsample.
> > > >
> > > > Case 1 (Visual blockwise <C-A> with TAB and SPACE mixed)
> > > > - Manipulate
> > > > $ vim -Nu NONE
> > > > :call setline(1, ["1234 56", "\<TAB>78"])
> > > > :exec "norm! ggw\<C-V>jl\<C-A>"
> > > > - Expect result
> > > > "1234 57"
> > > > "\<TAB>79"
> > > > - Unpatched result
> > > > "1235 56"
> > > > "\<TAB>79"
> > >
> > >
> > > I see, thanks for fixing that.
> > >
> > > > > To make reviewing easier, it would be good to first make a patch to
> > > > > change the test from old to new style. Then we know the test works
> > > > > with
> > > > > the old code.
> > > >
> > > > Okay. I attached simple patch that only convert to new style test of
> > > > test_increment.
> > >
> > > Thanks. The original test had a nice explanation of what it was doing.
> > > Although the new style test do have the assert_equal() calls that make
> > > it easier to see what is going on, the commands themselves are still a
> > > bit of a puzzle. Since the explanations were already written, we can
> > > keep them. Using the comment above the test function should work well.
> >
> > Indeed. I did it. Please check and include attached patch.
>
> Thanks!
Thanks for including this.
Patch 7.4.1072
https://groups.google.com/d/topic/vim_dev/_K0eQkIB5aY/discussion
>
> > BTW, The following changes I thought happy for test_increment.vim.
> > How do you like it?
>
> Yes, that's better than the arbitrary order we have now.
> Unfortunately it break test_quickfix, it makes an assumption about test
> function ordering. That needs to be fixed.
Thanks for including this too.
Patch 7.4.1071
https://groups.google.com/d/topic/vim_dev/p6IAS6bPFDU/discussion
Well, the next simple patch is about this.
> - We removed the halfway right-to-left processing.
> (Remove RLADDSUBFIX() macro)
> (This is causing the actual problem)
> $ vim -Nu NONE -c "set rightleft"
> i123 45<Esc>
> <C-A> " Unexpected swap the numbers of strings occurred.
Investigation result:
Reverse line process of 'rightleft' is performed by the display part.
therefore it doesn't need in do_addsub().
I've attached a patch containing the test.
Please check it.
--
Best regards,
Hirohito Higashi (a.k.a h_east)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ops.c b/src/ops.c
index d02b784..12978a8 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -5339,31 +5339,6 @@ block_prep(oap, bdp, lnum, is_del)
bdp->textstart = pstart;
}
-#ifdef FEAT_RIGHTLEFT
-static void reverse_line __ARGS((char_u *s));
-
- static void
-reverse_line(s)
- 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);
-#else
-# define RLADDSUBFIX(ptr)
-#endif
-
/*
* add or subtract 'Prenum1' from a number in a line
* 'command' is CTRL-A for add, CTRL-X for subtract
@@ -5426,7 +5401,6 @@ do_addsub(command, Prenum1, g_cmd)
}
ptr = ml_get(VIsual.lnum);
- RLADDSUBFIX(ptr);
if (VIsual_mode == 'V')
{
VIsual.col = 0;
@@ -5457,7 +5431,6 @@ do_addsub(command, Prenum1, g_cmd)
else
{
ptr = ml_get_curline();
- RLADDSUBFIX(ptr);
if (dobin)
while (col > 0 && vim_isbdigit(ptr[col]))
@@ -5526,7 +5499,6 @@ do_addsub(command, Prenum1, g_cmd)
t = curwin->w_cursor;
curwin->w_cursor.lnum = i;
ptr = ml_get_curline();
- RLADDSUBFIX(ptr);
if ((int)STRLEN(ptr) <= col)
/* try again on next line */
continue;
@@ -5812,10 +5784,6 @@ do_addsub(command, Prenum1, g_cmd)
col = 0;
Prenum1 += offset;
curwin->w_set_curswant = TRUE;
-#ifdef FEAT_RIGHTLEFT
- ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);
- RLADDSUBFIX(ptr);
-#endif
}
if (visual)
/* cursor at the top of the selection */
diff --git a/src/testdir/test_increment.vim b/src/testdir/test_increment.vim
index ab75c1c..277f71d 100644
--- a/src/testdir/test_increment.vim
+++ b/src/testdir/test_increment.vim
@@ -558,4 +558,21 @@ func Test_visual_increment_26()
call assert_equal([0, 1, 1, 0], getpos('.'))
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