Minor improvements to locked narrowing
* src/xdisp.c (get_locked_narrowing_begv) (get_locked_narrowing_zv): Safer handling of negative values. (handle_fontified_prop): Do not use locked narrowing if the region size is <= 0. * src/keyboard.c (safe_run_hooks_maybe_narrowed): Do not use locked narrowing if the region size is <= 0.
This commit is contained in:
parent
d5dc1dbf7c
commit
6d3cea2c8e
2 changed files with 7 additions and 5 deletions
|
@ -1910,7 +1910,8 @@ safe_run_hooks_maybe_narrowed (Lisp_Object hook, struct window *w)
|
|||
|
||||
specbind (Qinhibit_quit, Qt);
|
||||
|
||||
if (current_buffer->long_line_optimizations_p)
|
||||
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);
|
||||
|
|
|
@ -3536,12 +3536,12 @@ get_closer_narrowed_begv (struct window *w, ptrdiff_t pos)
|
|||
ptrdiff_t
|
||||
get_locked_narrowing_begv (ptrdiff_t pos)
|
||||
{
|
||||
if (long_line_locked_narrowing_region_size == 0)
|
||||
if (long_line_locked_narrowing_region_size <= 0)
|
||||
return BEGV;
|
||||
int len = long_line_locked_narrowing_region_size / 2;
|
||||
int begv = max (pos - len, BEGV);
|
||||
int limit = long_line_locked_narrowing_bol_search_limit;
|
||||
while (limit)
|
||||
while (limit > 0)
|
||||
{
|
||||
if (begv == BEGV || FETCH_BYTE (CHAR_TO_BYTE (begv) - 1) == '\n')
|
||||
return begv;
|
||||
|
@ -3554,7 +3554,7 @@ get_locked_narrowing_begv (ptrdiff_t pos)
|
|||
ptrdiff_t
|
||||
get_locked_narrowing_zv (ptrdiff_t pos)
|
||||
{
|
||||
if (long_line_locked_narrowing_region_size == 0)
|
||||
if (long_line_locked_narrowing_region_size <= 0)
|
||||
return ZV;
|
||||
int len = long_line_locked_narrowing_region_size / 2;
|
||||
return min (pos + len, ZV);
|
||||
|
@ -4393,7 +4393,8 @@ handle_fontified_prop (struct it *it)
|
|||
|
||||
eassert (it->end_charpos == ZV);
|
||||
|
||||
if (current_buffer->long_line_optimizations_p)
|
||||
if (current_buffer->long_line_optimizations_p
|
||||
&& long_line_locked_narrowing_region_size > 0)
|
||||
{
|
||||
ptrdiff_t begv = it->locked_narrowing_begv;
|
||||
ptrdiff_t zv = it->locked_narrowing_zv;
|
||||
|
|
Loading…
Add table
Reference in a new issue