From: Lars Ingebrigtsen Date: Tue, 9 Feb 2021 07:12:10 +0000 (+0100) Subject: Fix count-lines problem in non-ASCII buffers X-Git-Tag: emacs-28.0.90~3864 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f3fd9591cfca5450b4bc74274340f24068f96fc7;p=emacs.git Fix count-lines problem in non-ASCII buffers * src/fns.c (Fline_number_at_pos): Get the correct start position in non-ASCII buffers (bug#22763). --- diff --git a/src/fns.c b/src/fns.c index 02743c62a57..c16f9c63998 100644 --- a/src/fns.c +++ b/src/fns.c @@ -5769,7 +5769,7 @@ visible part of the buffer. If ABSOLUTE is non-nil, count the lines from the absolute start of the buffer. */) (register Lisp_Object position, Lisp_Object absolute) { - ptrdiff_t pos, start = BEGV; + ptrdiff_t pos, start = BEGV_BYTE; if (MARKERP (position)) pos = marker_position (position); diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index b4007a6c3f3..f2ddc2e3fb3 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el @@ -67,6 +67,11 @@ (insert (propertize "\nbar\nbaz\nzut" 'invisible t)) (should (= (count-lines (point-min) (point-max) t) 2)))) +(ert-deftest simple-text-count-lines-non-ascii () + (with-temp-buffer + (insert "あ\nい\nう\nえ\nお\n") + (should (= (count-lines (point) (point)) 0)))) + ;;; `transpose-sexps' (defmacro simple-test--transpositions (&rest body)