unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27281: Fix nlinum missing line numbers.
@ 2017-06-07 21:46 William Gilbert
  2017-06-10 11:51 ` npostavs
  0 siblings, 1 reply; 10+ messages in thread
From: William Gilbert @ 2017-06-07 21:46 UTC (permalink / raw)
  To: 27281

[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]

I've been working to track to down a bug where line numbers are
occasionally missing when using nlinum mode. Currently there is a package
written to workaround the problem that has a picture and description of the
problem: https://github.com/hlissner/emacs-nlinum-hl.

After extensive debugging I've tracked the problem down to the
'nlinum--region' function. Specifically the while loop check that
determines if '(point)' is less than the limit. I've found that the problem
exists when '(point)' is exactly equal to 'limit'. In this scenario the
loop terminates and the last line in the region is not provided with a line
number. I was able to remedy the problem by changing the condition from
'less than' to 'less than or equal to', which will allow the last line in
the region to be properly assigned a line number.

Thank you.

Diff:

diff --git a/packages/nlinum/nlinum.el b/packages/nlinum/nlinum.el
index ca4f949fc..f82b61987 100644
--- a/packages/nlinum/nlinum.el
+++ b/packages/nlinum/nlinum.el
@@ -303,7 +303,7 @@ it may cause the margin to be resized and line numbers
to be recomputed.")
       (remove-overlays (point) limit 'nlinum t)
       (let ((line (nlinum--line-number-at-pos)))
         (while
-            (and (not (eobp)) (< (point) limit)
+            (and (not (eobp)) (<= (point) limit)
                  (let* ((ol (make-overlay (point) (1+ (point))))
                         (str (funcall nlinum-format-function
                                       line nlinum--width))

[-- Attachment #2: Type: text/html, Size: 1895 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-09-29 15:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-07 21:46 bug#27281: Fix nlinum missing line numbers William Gilbert
2017-06-10 11:51 ` npostavs
2017-06-10 14:35   ` Bryan Gilbert
2017-06-10 17:44   ` Alex
2017-06-10 22:12     ` npostavs
2017-06-11  1:18       ` Alex
2017-06-11  1:37         ` npostavs
2017-06-11  2:37       ` Bryan Gilbert
2017-06-11  2:50         ` Bryan Gilbert
2019-09-29 15:04           ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).