From 56ab6203fa96a3bf203aa6bdcb11753ff0adf962 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Mon, 28 Nov 2022 01:20:46 +0000 Subject: [PATCH] Do not enter locked narrowing when it would span the whole buffer * src/xdisp.c (handle_fontified_prop): * src/keyboard.c (safe_run_hooks_maybe_narrowed): Add condition. --- src/keyboard.c | 9 ++++++--- src/xdisp.c | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index ac40ba059ea..d68b50428a9 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1912,9 +1912,12 @@ safe_run_hooks_maybe_narrowed (Lisp_Object hook, struct window *w) if (current_buffer->long_line_optimizations_p && long_line_locked_narrowing_region_size > 0) - narrow_to_region_locked (make_fixnum (get_locked_narrowing_begv (PT)), - make_fixnum (get_locked_narrowing_zv (PT)), - hook); + { + ptrdiff_t begv = get_locked_narrowing_begv (PT); + ptrdiff_t zv = get_locked_narrowing_zv (PT); + if (begv != BEG || zv != Z) + narrow_to_region_locked (make_fixnum (begv), make_fixnum (zv), hook); + } run_hook_with_args (2, ((Lisp_Object []) {hook, hook}), safe_run_hook_funcall); diff --git a/src/xdisp.c b/src/xdisp.c index d423a77bde0..b09aa6ec967 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4404,8 +4404,9 @@ handle_fontified_prop (struct it *it) begv = get_locked_narrowing_begv (charpos); zv = get_locked_narrowing_zv (charpos); } - narrow_to_region_locked (make_fixnum (begv), make_fixnum (zv), - Qfontification_functions); + if (begv != BEG || zv != Z) + narrow_to_region_locked (make_fixnum (begv), make_fixnum (zv), + Qfontification_functions); } /* Don't allow Lisp that runs from 'fontification-functions' -- 2.39.5