diff options
| author | Eli Zaretskii | 2017-06-30 22:48:36 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-06-30 22:48:36 +0300 |
| commit | a9be5a768b6c06e74a386c474aba8125dfc8ed86 (patch) | |
| tree | 1e54aa5d166cf5ed3942de70d31047f4e8cc6361 /src | |
| parent | e83b128a8195e5c63f12832decf70c2953821dc0 (diff) | |
| download | emacs-a9be5a768b6c06e74a386c474aba8125dfc8ed86.tar.gz emacs-a9be5a768b6c06e74a386c474aba8125dfc8ed86.zip | |
Fix relative-number display with non-nil display-line-number-width
* src/xdisp.c (maybe_produce_line_number): Don't treat a zero
value of display-line-number-width as acceptable.
Handle the case of 'relative' with display-line-number-width
non-nil and smaller than the absolute line number requires.
Reported by Alex <agrambot@gmail.com>.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index bcd7d33332f..aeccac2cb16 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -20867,26 +20867,23 @@ maybe_produce_line_number (struct it *it) | |||
| 20867 | { | 20867 | { |
| 20868 | if (NATNUMP (Vdisplay_line_number_width)) | 20868 | if (NATNUMP (Vdisplay_line_number_width)) |
| 20869 | it->lnum_width = XFASTINT (Vdisplay_line_number_width); | 20869 | it->lnum_width = XFASTINT (Vdisplay_line_number_width); |
| 20870 | |||
| 20871 | /* Max line number to be displayed cannot be more than the one | ||
| 20872 | corresponding to the last row of the desired matrix. */ | ||
| 20873 | ptrdiff_t max_lnum; | ||
| 20874 | |||
| 20875 | if (NILP (Vdisplay_line_numbers_current_absolute) | ||
| 20876 | && (EQ (Vdisplay_line_numbers, Qrelative) | ||
| 20877 | || EQ (Vdisplay_line_numbers, Qvisual))) | ||
| 20878 | /* We subtract one more because the current line is always | ||
| 20879 | zero in this mode. */ | ||
| 20880 | max_lnum = it->w->desired_matrix->nrows - 2; | ||
| 20881 | else if (EQ (Vdisplay_line_numbers, Qvisual)) | ||
| 20882 | max_lnum = it->pt_lnum + it->w->desired_matrix->nrows - 1; | ||
| 20870 | else | 20883 | else |
| 20871 | { | 20884 | max_lnum = this_line + it->w->desired_matrix->nrows - 1 - it->vpos; |
| 20872 | /* Max line number to be displayed cannot be more than | 20885 | max_lnum = max (1, max_lnum); |
| 20873 | the one corresponding to the last row of the desired | 20886 | it->lnum_width = max (it->lnum_width, log10 (max_lnum) + 1); |
| 20874 | matrix. */ | ||
| 20875 | ptrdiff_t max_lnum; | ||
| 20876 | |||
| 20877 | if (NILP (Vdisplay_line_numbers_current_absolute) | ||
| 20878 | && (EQ (Vdisplay_line_numbers, Qrelative) | ||
| 20879 | || EQ (Vdisplay_line_numbers, Qvisual))) | ||
| 20880 | /* We subtract one more because the current line is always | ||
| 20881 | zero in this mode. */ | ||
| 20882 | max_lnum = it->w->desired_matrix->nrows - 2; | ||
| 20883 | else if (EQ (Vdisplay_line_numbers, Qvisual)) | ||
| 20884 | max_lnum = it->pt_lnum + it->w->desired_matrix->nrows - 1; | ||
| 20885 | else | ||
| 20886 | max_lnum = this_line + it->w->desired_matrix->nrows - 1 - it->vpos; | ||
| 20887 | max_lnum = max (1, max_lnum); | ||
| 20888 | it->lnum_width = log10 (max_lnum) + 1; | ||
| 20889 | } | ||
| 20890 | eassert (it->lnum_width > 0); | 20887 | eassert (it->lnum_width > 0); |
| 20891 | } | 20888 | } |
| 20892 | if (EQ (Vdisplay_line_numbers, Qrelative)) | 20889 | if (EQ (Vdisplay_line_numbers, Qrelative)) |