Skip to content

Commit ff4538f

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 08572c2 + 99af91e commit ff4538f

File tree

8 files changed

+152
-43
lines changed

8 files changed

+152
-43
lines changed

runtime/filetype.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ au BufNewFile,BufRead configure.in,configure.ac setf config
404404
" Cooklang
405405
au BufNewFile,BufRead *.cook setf cook
406406

407+
" CSV Files
408+
au BufNewFile,BufRead *.csv setf csv
409+
407410
" CUDA Compute Unified Device Architecture
408411
au BufNewFile,BufRead *.cu,*.cuh setf cuda
409412

@@ -2028,6 +2031,9 @@ au BufNewFile,BufReadPost *.tssop setf tssop
20282031
" TSS - Command Line (temporary)
20292032
au BufNewFile,BufReadPost *.tsscl setf tsscl
20302033

2034+
" TSV Files
2035+
au BufNewFile,BufRead *.tsv setf tsv
2036+
20312037
" TWIG files
20322038
au BufNewFile,BufReadPost *.twig setf twig
20332039

src/drawline.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ win_line(
779779
trailcol = (colnr_T)STRLEN(ptr);
780780
while (trailcol > (colnr_T)0 && VIM_ISWHITE(ptr[trailcol - 1]))
781781
--trailcol;
782-
trailcol += (colnr_T) (ptr - line);
782+
trailcol += (colnr_T)(ptr - line);
783783
}
784784
// find end of leading whitespace
785785
if (wp->w_lcs_chars.lead || wp->w_lcs_chars.leadmultispace != NULL)
@@ -792,7 +792,7 @@ win_line(
792792
leadcol = (colnr_T)0;
793793
else
794794
// keep track of the first column not filled with spaces
795-
leadcol += (colnr_T) (ptr - line) + 1;
795+
leadcol += (colnr_T)(ptr - line) + 1;
796796
}
797797
}
798798

@@ -1027,12 +1027,14 @@ win_line(
10271027
// Repeat for the whole displayed line.
10281028
for (;;)
10291029
{
1030+
char_u *prev_ptr = ptr;
10301031
#if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA)
1031-
int has_match_conc = 0; // match wants to conceal
1032+
int has_match_conc = 0; // match wants to conceal
10321033
#endif
10331034
#ifdef FEAT_CONCEAL
1034-
int did_decrement_ptr = FALSE;
1035+
int did_decrement_ptr = FALSE;
10351036
#endif
1037+
10361038
// Skip this quickly when working on the text.
10371039
if (draw_state != WL_LINE)
10381040
{
@@ -1392,6 +1394,7 @@ win_line(
13921394
&match_conc, did_line_attr, lcs_eol_one,
13931395
&on_last_col);
13941396
ptr = line + v; // "line" may have been changed
1397+
prev_ptr = ptr;
13951398

13961399
// Do not allow a conceal over EOL otherwise EOL will be missed
13971400
// and bad things happen.
@@ -1553,6 +1556,7 @@ win_line(
15531556
// have made it invalid.
15541557
line = ml_get_buf(wp->w_buffer, lnum, FALSE);
15551558
ptr = line + v;
1559+
prev_ptr = ptr;
15561560
# ifdef FEAT_CONCEAL
15571561
// no concealing past the end of the line, it interferes
15581562
// with line highlighting
@@ -1733,9 +1737,10 @@ win_line(
17331737
else
17341738
{
17351739
#ifdef FEAT_LINEBREAK
1736-
int c0;
1740+
int c0;
17371741
#endif
17381742
VIM_CLEAR(p_extra_free);
1743+
prev_ptr = ptr;
17391744

17401745
// Get a character from the line itself.
17411746
c = *ptr;
@@ -1942,17 +1947,12 @@ win_line(
19421947
# endif
19431948
can_spell))
19441949
{
1945-
char_u *prev_ptr, *p;
1950+
char_u *p;
19461951
int len;
19471952
hlf_T spell_hlf = HLF_COUNT;
19481953

19491954
if (has_mbyte)
1950-
{
1951-
prev_ptr = ptr - mb_l;
19521955
v -= mb_l - 1;
1953-
}
1954-
else
1955-
prev_ptr = ptr - 1;
19561956

19571957
// Use nextline[] if possible, it has the start of the
19581958
// next line concatenated.
@@ -2775,6 +2775,7 @@ win_line(
27752775
}
27762776
#endif
27772777
ScreenAttrs[off] = char_attr;
2778+
ScreenCols[off] = MAXCOL;
27782779
#ifdef FEAT_RIGHTLEFT
27792780
if (wp->w_p_rl)
27802781
{
@@ -2843,6 +2844,7 @@ win_line(
28432844
ScreenLines[off] = ' ';
28442845
if (enc_utf8)
28452846
ScreenLinesUC[off] = 0;
2847+
ScreenCols[off] = MAXCOL;
28462848
++col;
28472849
if (draw_color_col)
28482850
draw_color_col = advance_color_col(VCOL_HLC,
@@ -2996,6 +2998,8 @@ win_line(
29962998
else
29972999
ScreenAttrs[off] = char_attr;
29983000

3001+
ScreenCols[off] = (colnr_T)(prev_ptr - line);
3002+
29993003
if (has_mbyte && (*mb_char2cells)(mb_c) > 1)
30003004
{
30013005
// Need to fill two screen columns.
@@ -3017,6 +3021,9 @@ win_line(
30173021
// the character, otherwise highlighting won't stop.
30183022
if (tocol == vcol)
30193023
++tocol;
3024+
3025+
ScreenCols[off] = (colnr_T)(prev_ptr - line);
3026+
30203027
#ifdef FEAT_RIGHTLEFT
30213028
if (wp->w_p_rl)
30223029
{

src/globals.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@ EXTERN long Columns INIT(= 80); // nr of columns in the screen
3232
* The characters that are currently on the screen are kept in ScreenLines[].
3333
* It is a single block of characters, the size of the screen plus one line.
3434
* The attributes for those characters are kept in ScreenAttrs[].
35+
* The byte offset in the line is kept in ScreenCols[].
3536
*
3637
* "LineOffset[n]" is the offset from ScreenLines[] for the start of line 'n'.
37-
* The same value is used for ScreenLinesUC[] and ScreenAttrs[].
38+
* The same value is used for ScreenLinesUC[], ScreenAttrs[] and ScreenCols[].
3839
*
3940
* Note: before the screen is initialized and when out of memory these can be
4041
* NULL.
4142
*/
4243
EXTERN schar_T *ScreenLines INIT(= NULL);
4344
EXTERN sattr_T *ScreenAttrs INIT(= NULL);
45+
EXTERN colnr_T *ScreenCols INIT(= NULL);
4446
EXTERN unsigned *LineOffset INIT(= NULL);
4547
EXTERN char_u *LineWraps INIT(= NULL); // line wraps to next line
4648

@@ -62,7 +64,7 @@ EXTERN int Screen_mco INIT(= 0); // value of p_mco used when
6264
EXTERN schar_T *ScreenLines2 INIT(= NULL);
6365

6466
/*
65-
* Buffer for one screen line (characters and attributes).
67+
* One screen line to be displayed. Points into ScreenLines.
6668
*/
6769
EXTERN schar_T *current_ScreenLine INIT(= NULL);
6870

src/mouse.c

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,8 +1561,9 @@ jump_to_mouse(
15611561
int first;
15621562
int row = mouse_row;
15631563
int col = mouse_col;
1564+
colnr_T col_from_screen = -1;
15641565
#ifdef FEAT_FOLDING
1565-
int mouse_char;
1566+
int mouse_char = ' ';
15661567
#endif
15671568

15681569
mouse_past_bottom = FALSE;
@@ -1644,16 +1645,6 @@ jump_to_mouse(
16441645
if (flags & MOUSE_SETPOS)
16451646
goto retnomove; // ugly goto...
16461647

1647-
#ifdef FEAT_FOLDING
1648-
// Remember the character under the mouse, it might be a '-' or '+' in the
1649-
// fold column.
1650-
if (row >= 0 && row < Rows && col >= 0 && col <= Columns
1651-
&& ScreenLines != NULL)
1652-
mouse_char = ScreenLines[LineOffset[row] + col];
1653-
else
1654-
mouse_char = ' ';
1655-
#endif
1656-
16571648
old_curwin = curwin;
16581649
old_cursor = curwin->w_cursor;
16591650

@@ -1987,6 +1978,22 @@ jump_to_mouse(
19871978
}
19881979
}
19891980

1981+
if (prev_row >= 0 && prev_row < Rows && prev_col >= 0 && prev_col <= Columns
1982+
&& ScreenLines != NULL)
1983+
{
1984+
int off = LineOffset[prev_row] + prev_col;
1985+
1986+
// Only use ScreenCols[] after the window was redrawn. Mainly matters
1987+
// for tests, a user would not click before redrawing.
1988+
if (curwin->w_redr_type <= VALID_NO_UPDATE)
1989+
col_from_screen = ScreenCols[off];
1990+
#ifdef FEAT_FOLDING
1991+
// Remember the character under the mouse, it might be a '-' or '+' in
1992+
// the fold column.
1993+
mouse_char = ScreenLines[off];
1994+
#endif
1995+
}
1996+
19901997
#ifdef FEAT_FOLDING
19911998
// Check for position outside of the fold column.
19921999
if (
@@ -2019,16 +2026,40 @@ jump_to_mouse(
20192026
redraw_cmdline = TRUE; // show visual mode later
20202027
}
20212028

2022-
curwin->w_curswant = col;
2023-
curwin->w_set_curswant = FALSE; // May still have been TRUE
2024-
if (coladvance(col) == FAIL) // Mouse click beyond end of line
2029+
if (col_from_screen >= 0)
2030+
{
2031+
// Use the column from ScreenCols[], it is accurate also after
2032+
// concealed characters.
2033+
curwin->w_cursor.col = col_from_screen;
2034+
if (col_from_screen == MAXCOL)
2035+
{
2036+
curwin->w_curswant = col_from_screen;
2037+
curwin->w_set_curswant = FALSE; // May still have been TRUE
2038+
mouse_past_eol = TRUE;
2039+
if (inclusive != NULL)
2040+
*inclusive = TRUE;
2041+
}
2042+
else
2043+
{
2044+
curwin->w_set_curswant = TRUE;
2045+
if (inclusive != NULL)
2046+
*inclusive = FALSE;
2047+
}
2048+
check_cursor_col();
2049+
}
2050+
else
20252051
{
2026-
if (inclusive != NULL)
2027-
*inclusive = TRUE;
2028-
mouse_past_eol = TRUE;
2052+
curwin->w_curswant = col;
2053+
curwin->w_set_curswant = FALSE; // May still have been TRUE
2054+
if (coladvance(col) == FAIL) // Mouse click beyond end of line
2055+
{
2056+
if (inclusive != NULL)
2057+
*inclusive = TRUE;
2058+
mouse_past_eol = TRUE;
2059+
}
2060+
else if (inclusive != NULL)
2061+
*inclusive = FALSE;
20292062
}
2030-
else if (inclusive != NULL)
2031-
*inclusive = FALSE;
20322063

20332064
count = IN_BUFFER;
20342065
if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum

0 commit comments

Comments
 (0)