Hi Christian,

On Thu, Sep 23, 2021 at 12:01 AM Christian Brabandt <[email protected]> wrote:
>
> > > > >
> > > > > > > Thanks for creating this test.
> > > > > > > There is another check for n_extra becoming negative, and if I 
> > > > > > > comment it
> > > > > > > out no test fails.
> > > > > > > Perhaps you can manage to write a test for that one too?
> > > > > > > This is in line 1215 of src/drawline.c
> > > > > >
> > > > > >
> > > > > > I created a test that exercises this line. But I ran into some bugs.
> > > > > > If you source the following script:
> > > > > >
> > > > > > -------------------------------------------------------------------------------------
> > > > > > 10new
> > > > > > 20vnew
> > > > > > call setline(1, repeat('aa ', 200))
> > > > > > setlocal breakindent breakindentopt=shift:4 linebreak showbreak=>>
> > > > > > setlocal number
> > > > > > set cpo+=n
> > > > > > normal 12gj
> > > > > > redraw!
> > > > > > normal $
> > > > > > redraw!
> > > > > >  
> > > > > > -------------------------------------------------------------------------------------
> > > > > >
> > > > > > You will see that the cursor is positioned a few characters before 
> > > > > > the end
> > > > > > of the line and it cannot be moved to the end of the line. Also, if 
> > > > > > you move
> > > > > > the cursor to the left by pressing "h" quite a few times (to cause 
> > > > > > the
> > > > > > screen
> > > > > > to scroll down), you will see the cursor can be positioned on the
> > > > > > 'showbreak' characters.
> > > > >
> > > > > It looks like this happens because the " >>" in the first line is not
> > > > > counted, thus when w_skipcol is non-zero.  It's also strange that 
> > > > > there
> > > > > is a space before ">>".  Perhaps Christian knows what needs to change 
> > > > > to
> > > > > fix this.
> > > >
> > > > I'll have a look.
> > > >
> > >
> > > Should I open a Github issue to track this?
> >
> > Hi Yegappan,
> > you can. I just don't have much spare time to debug such screen-logic.
>
> I found that time yesterday. I think the following patch should fix it.
> However I am not completely sure that this is the best way to do it. I
> also need some more time to thoroughly test it. I will do this later and
> submit a proper PR with your testcase.
>
> diff --git a/src/charset.c b/src/charset.c
> index fcaeedf75..953319af5 100644
> --- a/src/charset.c
> +++ b/src/charset.c
> @@ -1090,6 +1090,16 @@ win_lbr_chartabsize(
>         colnr_T sbrlen = 0;
>         int     numberwidth = win_col_off(wp);
>
> +       // long line that does not fit in the window
> +       // need to adjust for leading sbr value
> +       if (wp->w_skipcol &&
> +               wp->w_p_wrap &&
> +               col >= wp->w_skipcol &&
> +               *sbr != NUL &&
> +               col <= wp->w_skipcol + wp->w_width
> +               - win_col_off(wp) - MB_CHARLEN(sbr))
> +           col -= (colnr_T)MB_CHARLEN(sbr);
> +
>         numberextra = numberwidth;
>         col += numberextra + mb_added;
>         if (col >= (colnr_T)wp->w_width)
>
>

Thanks for the patch. When I tested the patch, I saw a couple of problems.

After executing the above script, if I press 0 and then $ to go to the end of
the line, the cursor is positioned a few characters before the end of the line.
I am not able to move the cursor to the right by pressing 'l'. But if
I press 'h'
once then the cursor is positioned at the end of the line.

Also, if I press 'h' several times to cause the buffer to scroll down,
after hitting
the beginning of the first screen line, the cursor jumps to the second character
in the second screen line. If I press 'h' now, then the cursor jumps
to the fourth
character in the second screen line.

Regards,
Yegappan

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7nAP4xffm0YaJU8f2MrQ0P6cGoRYwMZbR%3D709tE-Yh2Lg%40mail.gmail.com.

Raspunde prin e-mail lui