mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #5822 'mouse.c: Fix mouse click on multibyte + concealed'
This commit is contained in:
commit
397ff2c35b
117
src/nvim/mouse.c
117
src/nvim/mouse.c
@ -608,8 +608,7 @@ bool mouse_scroll_horiz(int dir)
|
|||||||
return leftcol_changed();
|
return leftcol_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust the clicked column position if there are concealed characters
|
/// Adjusts the clicked column position when 'conceallevel' > 0
|
||||||
// before the current column. But only when it's absolutely necessary.
|
|
||||||
static int mouse_adjust_click(win_T *wp, int row, int col)
|
static int mouse_adjust_click(win_T *wp, int row, int col)
|
||||||
{
|
{
|
||||||
if (!(wp->w_p_cole > 0 && curbuf->b_p_smc > 0
|
if (!(wp->w_p_cole > 0 && curbuf->b_p_smc > 0
|
||||||
@ -617,64 +616,102 @@ static int mouse_adjust_click(win_T *wp, int row, int col)
|
|||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
int end = (colnr_T)STRLEN(ml_get(wp->w_cursor.lnum));
|
// `col` is the position within the current line that is highlighted by the
|
||||||
int vend = getviscol2(end, 0);
|
// cursor without consideration for concealed characters. The current line is
|
||||||
|
// scanned *up to* `col`, nudging it left or right when concealed characters
|
||||||
|
// are encountered.
|
||||||
|
//
|
||||||
|
// chartabsize() is used to keep track of the virtual column position relative
|
||||||
|
// to the line's bytes. For example: if col == 9 and the line starts with a
|
||||||
|
// tab that's 8 columns wide, we would want the cursor to be highlighting the
|
||||||
|
// second byte, not the ninth.
|
||||||
|
|
||||||
if (col >= vend) {
|
linenr_T lnum = wp->w_cursor.lnum;
|
||||||
return col;
|
char_u *line = ml_get(lnum);
|
||||||
}
|
char_u *ptr = line;
|
||||||
|
char_u *ptr_end = line;
|
||||||
int i = wp->w_leftcol;
|
char_u *ptr_row_offset = line; // Where we begin adjusting `ptr_end`
|
||||||
|
|
||||||
|
// Find the offset where scanning should begin.
|
||||||
|
int offset = wp->w_leftcol;
|
||||||
if (row > 0) {
|
if (row > 0) {
|
||||||
i += row * (wp->w_width - win_col_off(wp) - win_col_off2(wp)
|
offset += row * (wp->w_width - win_col_off(wp) - win_col_off2(wp) -
|
||||||
- wp->w_leftcol) + wp->w_skipcol;
|
wp->w_leftcol + wp->w_skipcol);
|
||||||
|
}
|
||||||
|
|
||||||
|
int vcol;
|
||||||
|
|
||||||
|
if (offset) {
|
||||||
|
// Skip everything up to an offset since nvim takes care of displaying the
|
||||||
|
// correct portion of the line when horizontally scrolling.
|
||||||
|
// When 'wrap' is enabled, only the row (of the wrapped line) needs to be
|
||||||
|
// checked for concealed characters.
|
||||||
|
vcol = 0;
|
||||||
|
while (vcol < offset && *ptr != NUL) {
|
||||||
|
vcol += chartabsize(ptr, vcol);
|
||||||
|
ptr += utfc_ptr2len(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr_row_offset = ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Align `ptr_end` with `col`
|
||||||
|
vcol = offset;
|
||||||
|
ptr_end = ptr_row_offset;
|
||||||
|
while (vcol < col && *ptr_end != NUL) {
|
||||||
|
vcol += chartabsize(ptr_end, vcol);
|
||||||
|
ptr_end += utfc_ptr2len(ptr_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
int start_col = i;
|
|
||||||
int matchid;
|
int matchid;
|
||||||
int last_matchid;
|
int prev_matchid;
|
||||||
int bcol = end - (vend - col);
|
int nudge = 0;
|
||||||
|
int cwidth = 0;
|
||||||
|
|
||||||
while (i < bcol) {
|
vcol = offset;
|
||||||
matchid = syn_get_concealed_id(wp, wp->w_cursor.lnum, i);
|
|
||||||
|
|
||||||
|
#define incr() nudge++; ptr_end += utfc_ptr2len(ptr_end)
|
||||||
|
#define decr() nudge--; ptr_end -= utfc_ptr2len(ptr_end)
|
||||||
|
|
||||||
|
while (ptr < ptr_end && *ptr != NUL) {
|
||||||
|
cwidth = chartabsize(ptr, vcol);
|
||||||
|
vcol += cwidth;
|
||||||
|
if (cwidth > 1 && *ptr == '\t' && nudge > 0) {
|
||||||
|
// A tab will "absorb" any previous adjustments.
|
||||||
|
cwidth = MIN(cwidth, nudge);
|
||||||
|
while (cwidth > 0) {
|
||||||
|
decr();
|
||||||
|
cwidth--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
matchid = syn_get_concealed_id(wp, lnum, (colnr_T)(ptr - line));
|
||||||
if (matchid != 0) {
|
if (matchid != 0) {
|
||||||
if (wp->w_p_cole == 3) {
|
if (wp->w_p_cole == 3) {
|
||||||
bcol++;
|
incr();
|
||||||
} else {
|
} else {
|
||||||
if (row > 0 && i == start_col) {
|
if (!(row > 0 && ptr == ptr_row_offset)
|
||||||
// Check if the current concealed character is actually part of
|
&& (wp->w_p_cole == 1 || (wp->w_p_cole == 2
|
||||||
// the previous wrapped row's conceal group.
|
&& (lcs_conceal != NUL
|
||||||
last_matchid = syn_get_concealed_id(wp, wp->w_cursor.lnum,
|
|| syn_get_sub_char() != NUL)))) {
|
||||||
i - 1);
|
|
||||||
if (last_matchid == matchid) {
|
|
||||||
bcol++;
|
|
||||||
}
|
|
||||||
} else if (wp->w_p_cole == 1
|
|
||||||
|| (wp->w_p_cole == 2
|
|
||||||
&& (lcs_conceal != NUL
|
|
||||||
|| syn_get_sub_char() != NUL))) {
|
|
||||||
// At least one placeholder character will be displayed.
|
// At least one placeholder character will be displayed.
|
||||||
bcol--;
|
decr();
|
||||||
}
|
}
|
||||||
|
|
||||||
last_matchid = matchid;
|
prev_matchid = matchid;
|
||||||
|
|
||||||
// Adjust for concealed text that spans more than one character.
|
while (prev_matchid == matchid && *ptr != NUL) {
|
||||||
do {
|
incr();
|
||||||
i++;
|
ptr += utfc_ptr2len(ptr);
|
||||||
bcol++;
|
matchid = syn_get_concealed_id(wp, lnum, (colnr_T)(ptr - line));
|
||||||
matchid = syn_get_concealed_id(wp, wp->w_cursor.lnum, i);
|
}
|
||||||
} while (last_matchid == matchid);
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
ptr += utfc_ptr2len(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getviscol2(bcol, 0);
|
return col + nudge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,17 +750,19 @@ describe('ui/mouse/input', function()
|
|||||||
|
|
||||||
feed_command('set concealcursor=n')
|
feed_command('set concealcursor=n')
|
||||||
feed_command('set nowrap')
|
feed_command('set nowrap')
|
||||||
feed_command('syntax match NonText "\\<amet\\>" conceal')
|
feed_command('set shiftwidth=2 tabstop=4 list listchars=tab:>-')
|
||||||
feed_command('syntax match NonText "\\cs\\|g." conceal cchar=X')
|
feed_command('syntax match NonText "\\*" conceal')
|
||||||
feed_command('syntax match NonText "\\%(lo\\|cl\\)." conceal')
|
feed_command('syntax match NonText "cats" conceal cchar=X')
|
||||||
feed_command('syntax match NonText "Lo" conceal cchar=Y')
|
feed_command('syntax match NonText "x" conceal cchar=>')
|
||||||
|
|
||||||
|
-- First column is there to retain the tabs.
|
||||||
insert([[
|
insert([[
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
|
|Section *t1*
|
||||||
Stet clita kasd gubergren, no sea takimata sanctus est.
|
| *t2* *t3* *t4*
|
||||||
|
|x 私は猫が大好き *cats* ✨🐈✨
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('gg')
|
feed('gg<c-v>Gxgg')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('(level 1) click on non-wrapped lines', function()
|
it('(level 1) click on non-wrapped lines', function()
|
||||||
@ -768,93 +770,138 @@ describe('ui/mouse/input', function()
|
|||||||
|
|
||||||
feed('<esc><LeftMouse><0,0>')
|
feed('<esc><LeftMouse><0,0>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:^Y}rem ip{c:X}um do{c: } {c:X}it {c: }, con|
|
^Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
{c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en, no|
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c: X } {0:>}|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><1,0>')
|
feed('<esc><LeftMouse><1,0>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}^rem ip{c:X}um do{c: } {c:X}it {c: }, con|
|
S^ection{0:>>--->--->---}{c: }t1{c: } |
|
||||||
{c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en, no|
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c: X } {0:>}|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,0>')
|
feed('<esc><LeftMouse><21,0>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do{c: } {c:^X}it {c: }, con|
|
Section{0:>>--->--->---}{c: }^t1{c: } |
|
||||||
{c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en, no|
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c: X } {0:>}|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,1>')
|
feed('<esc><LeftMouse><21,1>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do{c: } {c:X}it {c: }, con|
|
Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
{c:X}tet {c: }ta ka{c:X}d {c:X}^ber{c:X}en, no|
|
{0:>--->--->---} {c: }t2{c: } {c: }t^3{c: } {c: }|
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c: X } {0:>}|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><0,2>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
|
{c:^>} 私は猫が大好き{0:>---}{c: X } {0:>}|
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><7,2>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
|
{c:>} 私は^猫が大好き{0:>---}{c: X } {0:>}|
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><21,2>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c: ^X } {0:>}|
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
end) -- level 1 - non wrapped
|
end) -- level 1 - non wrapped
|
||||||
|
|
||||||
it('(level 1) click on wrapped lines', function()
|
it('(level 1) click on wrapped lines', function()
|
||||||
feed_command('let &conceallevel=1', 'let &wrap=1', 'echo')
|
feed_command('let &conceallevel=1', 'let &wrap=1', 'echo')
|
||||||
|
|
||||||
feed('<esc><LeftMouse><0,0>')
|
feed('<esc><LeftMouse><24,1>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:^Y}rem ip{c:X}um do{c: } {c:X}it {c: } |
|
Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
, con{c:X}etetur {c:X}adip{c:X}cin{c:X} |
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c:^ }|
|
||||||
elitr. |
|
t4{c: } |
|
||||||
{c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en |
|
{c:>} 私は猫が大好き{0:>---}{c: X} |
|
||||||
, no {c:X}ea takimata {c:X}anctu{c:X}|
|
{c: } ✨🐈✨ |
|
||||||
e{c:X}t. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><6,1>')
|
feed('<esc><LeftMouse><0,2>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do{c: } {c:X}it {c: } |
|
Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
, con{c:X}^etetur {c:X}adip{c:X}cin{c:X} |
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
elitr. |
|
^t4{c: } |
|
||||||
{c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en |
|
{c:>} 私は猫が大好き{0:>---}{c: X} |
|
||||||
, no {c:X}ea takimata {c:X}anctu{c:X}|
|
{c: } ✨🐈✨ |
|
||||||
e{c:X}t. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,1>')
|
feed('<esc><LeftMouse><8,3>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do{c: } {c:X}it {c: } |
|
Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
, con{c:X}etetur {c:X}a^dip{c:X}cin{c:X} |
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
elitr. |
|
t4{c: } |
|
||||||
{c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en |
|
{c:>} 私は猫^が大好き{0:>---}{c: X} |
|
||||||
, no {c:X}ea takimata {c:X}anctu{c:X}|
|
{c: } ✨🐈✨ |
|
||||||
e{c:X}t. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,3>')
|
feed('<esc><LeftMouse><21,3>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do{c: } {c:X}it {c: } |
|
Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
, con{c:X}etetur {c:X}adip{c:X}cin{c:X} |
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
elitr. |
|
t4{c: } |
|
||||||
{c:X}tet {c: }ta ka{c:X}d {c:X}^ber{c:X}en |
|
{c:>} 私は猫が大好き{0:>---}{c: ^X} |
|
||||||
, no {c:X}ea takimata {c:X}anctu{c:X}|
|
{c: } ✨🐈✨ |
|
||||||
e{c:X}t. |
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><4,4>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}{c: }t1{c: } |
|
||||||
|
{0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
|
||||||
|
t4{c: } |
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c: X} |
|
||||||
|
{c: } ✨^🐈✨ |
|
||||||
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end) -- level 1 - wrapped
|
end) -- level 1 - wrapped
|
||||||
@ -863,45 +910,67 @@ describe('ui/mouse/input', function()
|
|||||||
it('(level 2) click on non-wrapped lines', function()
|
it('(level 2) click on non-wrapped lines', function()
|
||||||
feed_command('let &conceallevel=2', 'echo')
|
feed_command('let &conceallevel=2', 'echo')
|
||||||
|
|
||||||
feed('<esc><LeftMouse><0,0>')
|
feed('<esc><LeftMouse><20,0>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:^Y}rem ip{c:X}um do {c:X}it , con{c:X}e|
|
Section{0:>>--->--->---}^t1 |
|
||||||
{c:X}tet ta ka{c:X}d {c:X}ber{c:X}en, no |
|
{0:>--->--->---} t2 t3 t4 |
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><1,0>')
|
feed('<esc><LeftMouse><14,1>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}^rem ip{c:X}um do {c:X}it , con{c:X}e|
|
Section{0:>>--->--->---}t1 |
|
||||||
{c:X}tet ta ka{c:X}d {c:X}ber{c:X}en, no |
|
{0:>--->--->---} ^t2 t3 t4 |
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,0>')
|
feed('<esc><LeftMouse><18,1>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do {c:X}^it , con{c:X}e|
|
Section{0:>>--->--->---}t1 |
|
||||||
{c:X}tet ta ka{c:X}d {c:X}ber{c:X}en, no |
|
{0:>--->--->---} t2 t^3 t4 |
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,1>')
|
feed('<esc><LeftMouse><0,2>') -- Weirdness
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do {c:X}it , con{c:X}e|
|
Section{0:>>--->--->---}t1 |
|
||||||
{c:X}tet ta ka{c:X}d {c:X}b^er{c:X}en, no |
|
{0:>--->--->---} t2 t3 t4 |
|
||||||
|
{c:^>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><8,2>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 t4 |
|
||||||
|
{c:>} 私は猫^が大好き{0:>---}{c:X} ✨{0:>}|
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><20,2>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 t4 |
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c:^X} ✨{0:>}|
|
||||||
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
@ -911,47 +980,108 @@ describe('ui/mouse/input', function()
|
|||||||
it('(level 2) click on wrapped lines', function()
|
it('(level 2) click on wrapped lines', function()
|
||||||
feed_command('let &conceallevel=2', 'let &wrap=1', 'echo')
|
feed_command('let &conceallevel=2', 'let &wrap=1', 'echo')
|
||||||
|
|
||||||
feed('<esc><LeftMouse><0,0>')
|
feed('<esc><LeftMouse><20,0>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:^Y}rem ip{c:X}um do {c:X}it |
|
Section{0:>>--->--->---}^t1 |
|
||||||
, con{c:X}etetur {c:X}adip{c:X}cin{c:X} |
|
{0:>--->--->---} t2 t3 |
|
||||||
elitr. |
|
t4 |
|
||||||
{c:X}tet ta ka{c:X}d {c:X}ber{c:X}en |
|
{c:>} 私は猫が大好き{0:>---}{c:X} |
|
||||||
, no {c:X}ea takimata {c:X}anctu{c:X}|
|
✨🐈✨ |
|
||||||
e{c:X}t. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><6,1>')
|
feed('<esc><LeftMouse><14,1>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do {c:X}it |
|
Section{0:>>--->--->---}t1 |
|
||||||
, con{c:X}^etetur {c:X}adip{c:X}cin{c:X} |
|
{0:>--->--->---} ^t2 t3 |
|
||||||
elitr. |
|
t4 |
|
||||||
{c:X}tet ta ka{c:X}d {c:X}ber{c:X}en |
|
{c:>} 私は猫が大好き{0:>---}{c:X} |
|
||||||
, no {c:X}ea takimata {c:X}anctu{c:X}|
|
✨🐈✨ |
|
||||||
e{c:X}t. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,1>')
|
feed('<esc><LeftMouse><18,1>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do {c:X}it |
|
Section{0:>>--->--->---}t1 |
|
||||||
, con{c:X}etetur {c:X}a^dip{c:X}cin{c:X} |
|
{0:>--->--->---} t2 t^3 |
|
||||||
elitr. |
|
t4 |
|
||||||
{c:X}tet ta ka{c:X}d {c:X}ber{c:X}en |
|
{c:>} 私は猫が大好き{0:>---}{c:X} |
|
||||||
, no {c:X}ea takimata {c:X}anctu{c:X}|
|
✨🐈✨ |
|
||||||
e{c:X}t. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,3>')
|
-- NOTE: The click would ideally be on the 't' in 't4', but wrapping
|
||||||
|
-- caused the invisible '*' right before 't4' to remain on the previous
|
||||||
|
-- screen line. This is being treated as expected because fixing this is
|
||||||
|
-- out of scope for mouse clicks. Should the wrapping behavior of
|
||||||
|
-- concealed characters change in the future, this case should be
|
||||||
|
-- reevaluated.
|
||||||
|
feed('<esc><LeftMouse><0,2>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{c:Y}rem ip{c:X}um do {c:X}it |
|
Section{0:>>--->--->---}t1 |
|
||||||
, con{c:X}etetur {c:X}adip{c:X}cin{c:X} |
|
{0:>--->--->---} t2 t3 ^ |
|
||||||
elitr. |
|
t4 |
|
||||||
{c:X}tet ta ka{c:X}d {c:X}b^er{c:X}en |
|
{c:>} 私は猫が大好き{0:>---}{c:X} |
|
||||||
, no {c:X}ea takimata {c:X}anctu{c:X}|
|
✨🐈✨ |
|
||||||
e{c:X}t. |
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><1,2>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 |
|
||||||
|
t^4 |
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c:X} |
|
||||||
|
✨🐈✨ |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><0,3>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 |
|
||||||
|
t4 |
|
||||||
|
{c:^>} 私は猫が大好き{0:>---}{c:X} |
|
||||||
|
✨🐈✨ |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><20,3>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 |
|
||||||
|
t4 |
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c:^X} |
|
||||||
|
✨🐈✨ |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><1,4>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 |
|
||||||
|
t4 |
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c:X} |
|
||||||
|
^✨🐈✨ |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><5,4>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 |
|
||||||
|
t4 |
|
||||||
|
{c:>} 私は猫が大好き{0:>---}{c:X} |
|
||||||
|
✨🐈^✨ |
|
||||||
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end) -- level 2 - wrapped
|
end) -- level 2 - wrapped
|
||||||
@ -960,46 +1090,46 @@ describe('ui/mouse/input', function()
|
|||||||
it('(level 3) click on non-wrapped lines', function()
|
it('(level 3) click on non-wrapped lines', function()
|
||||||
feed_command('let &conceallevel=3', 'echo')
|
feed_command('let &conceallevel=3', 'echo')
|
||||||
|
|
||||||
feed('<esc><LeftMouse><0,0>')
|
feed('<esc><LeftMouse><0,2>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^rem ipum do it , conetetu|
|
Section{0:>>--->--->---}t1 |
|
||||||
tet ta kad beren, no ea t|
|
{0:>--->--->---} t2 t3 t4 |
|
||||||
|
^ 私は猫が大好き{0:>----} ✨🐈|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><1,0>')
|
feed('<esc><LeftMouse><1,2>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
r^em ipum do it , conetetu|
|
Section{0:>>--->--->---}t1 |
|
||||||
tet ta kad beren, no ea t|
|
{0:>--->--->---} t2 t3 t4 |
|
||||||
|
^私は猫が大好き{0:>----} ✨🐈|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,0>')
|
feed('<esc><LeftMouse><13,2>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
rem ipum do it ^, conetetu|
|
Section{0:>>--->--->---}t1 |
|
||||||
tet ta kad beren, no ea t|
|
{0:>--->--->---} t2 t3 t4 |
|
||||||
|
私は猫が大好^き{0:>----} ✨🐈|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,1>')
|
feed('<esc><LeftMouse><20,2>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
rem ipum do it , conetetu|
|
Section{0:>>--->--->---}t1 |
|
||||||
tet ta kad bere^n, no ea t|
|
{0:>--->--->---} t2 t3 t4 |
|
||||||
|
私は猫が大好き{0:>----}^ ✨🐈|
|
||||||
|
|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
@ -1008,49 +1138,94 @@ describe('ui/mouse/input', function()
|
|||||||
it('(level 3) click on wrapped lines', function()
|
it('(level 3) click on wrapped lines', function()
|
||||||
feed_command('let &conceallevel=3', 'let &wrap=1', 'echo')
|
feed_command('let &conceallevel=3', 'let &wrap=1', 'echo')
|
||||||
|
|
||||||
feed('<esc><LeftMouse><0,0>')
|
feed('<esc><LeftMouse><14,1>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^rem ipum do it |
|
Section{0:>>--->--->---}t1 |
|
||||||
, conetetur adipcin |
|
{0:>--->--->---} ^t2 t3 |
|
||||||
elitr. |
|
t4 |
|
||||||
tet ta kad beren |
|
私は猫が大好き{0:>----} |
|
||||||
, no ea takimata anctu |
|
✨🐈✨ |
|
||||||
et. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><6,1>')
|
feed('<esc><LeftMouse><18,1>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
rem ipum do it |
|
Section{0:>>--->--->---}t1 |
|
||||||
, cone^tetur adipcin |
|
{0:>--->--->---} t2 t^3 |
|
||||||
elitr. |
|
t4 |
|
||||||
tet ta kad beren |
|
私は猫が大好き{0:>----} |
|
||||||
, no ea takimata anctu |
|
✨🐈✨ |
|
||||||
et. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,1>')
|
feed('<esc><LeftMouse><1,2>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
rem ipum do it |
|
Section{0:>>--->--->---}t1 |
|
||||||
, conetetur adi^pcin |
|
{0:>--->--->---} t2 t3 |
|
||||||
elitr. |
|
t^4 |
|
||||||
tet ta kad beren |
|
私は猫が大好き{0:>----} |
|
||||||
, no ea takimata anctu |
|
✨🐈✨ |
|
||||||
et. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('<esc><LeftMouse><15,3>')
|
feed('<esc><LeftMouse><0,3>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
rem ipum do it |
|
Section{0:>>--->--->---}t1 |
|
||||||
, conetetur adipcin |
|
{0:>--->--->---} t2 t3 |
|
||||||
elitr. |
|
t4 |
|
||||||
tet ta kad bere^n |
|
^ 私は猫が大好き{0:>----} |
|
||||||
, no ea takimata anctu |
|
✨🐈✨ |
|
||||||
et. |
|
|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><20,3>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 |
|
||||||
|
t4 |
|
||||||
|
私は猫が大好き{0:>----}^ |
|
||||||
|
✨🐈✨ |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><1,4>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 |
|
||||||
|
t4 |
|
||||||
|
私は猫が大好き{0:>----} |
|
||||||
|
^✨🐈✨ |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><3,4>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 |
|
||||||
|
t4 |
|
||||||
|
私は猫が大好き{0:>----} |
|
||||||
|
✨^🐈✨ |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<esc><LeftMouse><5,4>')
|
||||||
|
screen:expect([[
|
||||||
|
Section{0:>>--->--->---}t1 |
|
||||||
|
{0:>--->--->---} t2 t3 |
|
||||||
|
t4 |
|
||||||
|
私は猫が大好き{0:>----} |
|
||||||
|
✨🐈^✨ |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
end) -- level 3 - wrapped
|
end) -- level 3 - wrapped
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user