mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 03:28:33 +00:00
vim-patch:7.4.603
Problem: 'foldcolumn' may be set such that it fills the whole window, not
leaving space for text.
Solution: Reduce the foldcolumn width when there is not sufficient room.
(idea by Christian Brabandt)
1c93429c48
This commit is contained in:
@@ -752,10 +752,11 @@ static void win_update(win_T *wp)
|
|||||||
lnumt = wp->w_lines[i].wl_lastlnum + 1;
|
lnumt = wp->w_lines[i].wl_lastlnum + 1;
|
||||||
if (lnumb == MAXLNUM && wp->w_lines[i].wl_lnum >= mod_bot) {
|
if (lnumb == MAXLNUM && wp->w_lines[i].wl_lnum >= mod_bot) {
|
||||||
lnumb = wp->w_lines[i].wl_lnum;
|
lnumb = wp->w_lines[i].wl_lnum;
|
||||||
/* When there is a fold column it might need updating
|
// When there is a fold column it might need updating
|
||||||
* in the next line ("J" just above an open fold). */
|
// in the next line ("J" just above an open fold).
|
||||||
if (wp->w_p_fdc > 0)
|
if (compute_foldcolumn(wp, 0) > 0) {
|
||||||
++lnumb;
|
lnumb++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1567,10 +1568,11 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h
|
|||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
# define FDC_OFF n
|
# define FDC_OFF n
|
||||||
|
int fdc = compute_foldcolumn(wp, 0);
|
||||||
|
|
||||||
if (wp->w_p_rl) {
|
if (wp->w_p_rl) {
|
||||||
/* No check for cmdline window: should never be right-left. */
|
// No check for cmdline window: should never be right-left.
|
||||||
n = wp->w_p_fdc;
|
n = fdc;
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
/* draw the fold column at the right */
|
/* draw the fold column at the right */
|
||||||
@@ -1610,8 +1612,8 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h
|
|||||||
wp->w_wincol, wp->w_wincol + n,
|
wp->w_wincol, wp->w_wincol + n,
|
||||||
cmdwin_type, ' ', hl_attr(HLF_AT));
|
cmdwin_type, ' ', hl_attr(HLF_AT));
|
||||||
}
|
}
|
||||||
if (wp->w_p_fdc > 0) {
|
if (fdc > 0) {
|
||||||
int nn = n + wp->w_p_fdc;
|
int nn = n + fdc;
|
||||||
|
|
||||||
/* draw the fold column at the left */
|
/* draw the fold column at the left */
|
||||||
if (nn > wp->w_width)
|
if (nn > wp->w_width)
|
||||||
@@ -1654,6 +1656,20 @@ static int advance_color_col(int vcol, int **color_cols)
|
|||||||
return **color_cols >= 0;
|
return **color_cols >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute the width of the foldcolumn. Based on 'foldcolumn' and how much
|
||||||
|
// space is available for window "wp", minus "col".
|
||||||
|
static int compute_foldcolumn(win_T *wp, int col)
|
||||||
|
{
|
||||||
|
int fdc = wp->w_p_fdc;
|
||||||
|
int wmw = wp == curwin && p_wmw == 0 ? 1 : p_wmw;
|
||||||
|
int wwidth = wp->w_width;
|
||||||
|
|
||||||
|
if (fdc > wwidth - (col + wmw)) {
|
||||||
|
fdc = wwidth - (col + wmw);
|
||||||
|
}
|
||||||
|
return fdc;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Display one folded line.
|
* Display one folded line.
|
||||||
*/
|
*/
|
||||||
@@ -1692,12 +1708,9 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
|
|||||||
++col;
|
++col;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// 2. Add the 'foldcolumn'
|
||||||
* 2. Add the 'foldcolumn'
|
// Reduce the width when there is not enough space.
|
||||||
*/
|
fdc = compute_foldcolumn(wp, col);
|
||||||
fdc = wp->w_p_fdc;
|
|
||||||
if (fdc > wp->w_width - col)
|
|
||||||
fdc = wp->w_width - col;
|
|
||||||
if (fdc > 0) {
|
if (fdc > 0) {
|
||||||
fill_foldcolumn(buf, wp, TRUE, lnum);
|
fill_foldcolumn(buf, wp, TRUE, lnum);
|
||||||
if (wp->w_p_rl) {
|
if (wp->w_p_rl) {
|
||||||
@@ -2018,37 +2031,42 @@ fill_foldcolumn (
|
|||||||
int level;
|
int level;
|
||||||
int first_level;
|
int first_level;
|
||||||
int empty;
|
int empty;
|
||||||
|
int fdc = compute_foldcolumn(wp, 0);
|
||||||
|
|
||||||
/* Init to all spaces. */
|
// Init to all spaces.
|
||||||
memset(p, ' ', (size_t)wp->w_p_fdc);
|
memset(p, ' ', (size_t)fdc);
|
||||||
|
|
||||||
level = win_foldinfo.fi_level;
|
level = win_foldinfo.fi_level;
|
||||||
if (level > 0) {
|
if (level > 0) {
|
||||||
/* If there is only one column put more info in it. */
|
// If there is only one column put more info in it.
|
||||||
empty = (wp->w_p_fdc == 1) ? 0 : 1;
|
empty = (fdc == 1) ? 0 : 1;
|
||||||
|
|
||||||
/* If the column is too narrow, we start at the lowest level that
|
// If the column is too narrow, we start at the lowest level that
|
||||||
* fits and use numbers to indicated the depth. */
|
// fits and use numbers to indicated the depth.
|
||||||
first_level = level - wp->w_p_fdc - closed + 1 + empty;
|
first_level = level - fdc - closed + 1 + empty;
|
||||||
if (first_level < 1)
|
if (first_level < 1) {
|
||||||
first_level = 1;
|
first_level = 1;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i + empty < wp->w_p_fdc; ++i) {
|
for (i = 0; i + empty < fdc; i++) {
|
||||||
if (win_foldinfo.fi_lnum == lnum
|
if (win_foldinfo.fi_lnum == lnum
|
||||||
&& first_level + i >= win_foldinfo.fi_low_level)
|
&& first_level + i >= win_foldinfo.fi_low_level) {
|
||||||
p[i] = '-';
|
p[i] = '-';
|
||||||
else if (first_level == 1)
|
} else if (first_level == 1) {
|
||||||
p[i] = '|';
|
p[i] = '|';
|
||||||
else if (first_level + i <= 9)
|
} else if (first_level + i <= 9) {
|
||||||
p[i] = '0' + first_level + i;
|
p[i] = '0' + first_level + i;
|
||||||
else
|
} else {
|
||||||
p[i] = '>';
|
p[i] = '>';
|
||||||
if (first_level + i == level)
|
}
|
||||||
|
if (first_level + i == level) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (closed)
|
if (closed) {
|
||||||
p[i >= wp->w_p_fdc ? i - 1 : i] = '+';
|
p[i >= fdc ? i - 1 : i] = '+';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2629,11 +2647,13 @@ win_line (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (draw_state == WL_FOLD - 1 && n_extra == 0) {
|
if (draw_state == WL_FOLD - 1 && n_extra == 0) {
|
||||||
|
int fdc = compute_foldcolumn(wp, 0);
|
||||||
|
|
||||||
draw_state = WL_FOLD;
|
draw_state = WL_FOLD;
|
||||||
if (wp->w_p_fdc > 0) {
|
if (fdc > 0) {
|
||||||
/* Draw the 'foldcolumn'. */
|
// Draw the 'foldcolumn'.
|
||||||
fill_foldcolumn(extra, wp, FALSE, lnum);
|
fill_foldcolumn(extra, wp, false, lnum);
|
||||||
n_extra = wp->w_p_fdc;
|
n_extra = fdc;
|
||||||
p_extra = extra;
|
p_extra = extra;
|
||||||
p_extra[n_extra] = NUL;
|
p_extra[n_extra] = NUL;
|
||||||
c_extra = NUL;
|
c_extra = NUL;
|
||||||
|
@@ -521,7 +521,7 @@ static int included_patches[] = {
|
|||||||
606,
|
606,
|
||||||
605,
|
605,
|
||||||
604,
|
604,
|
||||||
// 603,
|
603,
|
||||||
602,
|
602,
|
||||||
601,
|
601,
|
||||||
600,
|
600,
|
||||||
|
Reference in New Issue
Block a user