Use character position for ranges in treesit_sync_visible_region
* src/treesit.c (treesit_sync_visible_region): Use character position instead of byte position when comparing to ranges, because the ranges are in character position.
This commit is contained in:
parent
9c1d13c89a
commit
2dbf7d0b1b
1 changed files with 10 additions and 10 deletions
|
@ -1072,12 +1072,12 @@ treesit_sync_visible_region (Lisp_Object parser)
|
||||||
ptrdiff_t beg = XFIXNUM (XCAR (range));
|
ptrdiff_t beg = XFIXNUM (XCAR (range));
|
||||||
ptrdiff_t end = XFIXNUM (XCDR (range));
|
ptrdiff_t end = XFIXNUM (XCDR (range));
|
||||||
|
|
||||||
if (end <= visible_beg)
|
if (end <= BUF_BEGV (buffer))
|
||||||
/* Even the end is before visible_beg, discard this range. */
|
/* Even the end is before BUF_BEGV (buffer), discard this range. */
|
||||||
new_ranges_head = XCDR (new_ranges_head);
|
new_ranges_head = XCDR (new_ranges_head);
|
||||||
else if (beg >= visible_end)
|
else if (beg >= BUF_ZV (buffer))
|
||||||
{
|
{
|
||||||
/* Even the beg is after visible_end, discard this range and all
|
/* Even the beg is after BUF_ZV (buffer), discard this range and all
|
||||||
the ranges after it. */
|
the ranges after it. */
|
||||||
if (NILP (prev_cons))
|
if (NILP (prev_cons))
|
||||||
new_ranges_head = Qnil;
|
new_ranges_head = Qnil;
|
||||||
|
@ -1090,10 +1090,10 @@ treesit_sync_visible_region (Lisp_Object parser)
|
||||||
/* At this point, the range overlaps with the visible portion of
|
/* At this point, the range overlaps with the visible portion of
|
||||||
the buffer in some way (in front / in back / completely
|
the buffer in some way (in front / in back / completely
|
||||||
encased / completely encases). */
|
encased / completely encases). */
|
||||||
if (beg < visible_beg)
|
if (beg < BUF_BEGV (buffer))
|
||||||
XSETCAR (range, make_fixnum (visible_beg));
|
XSETCAR (range, make_fixnum (BUF_BEGV (buffer)));
|
||||||
if (end > visible_end)
|
if (end > BUF_ZV (buffer))
|
||||||
XSETCDR (range, make_fixnum (visible_end));
|
XSETCDR (range, make_fixnum (BUF_ZV (buffer)));
|
||||||
}
|
}
|
||||||
prev_cons = lisp_ranges;
|
prev_cons = lisp_ranges;
|
||||||
}
|
}
|
||||||
|
@ -1103,8 +1103,8 @@ treesit_sync_visible_region (Lisp_Object parser)
|
||||||
options, so just throw the towel: just give the parser a zero
|
options, so just throw the towel: just give the parser a zero
|
||||||
range. (Perfect filling!!) */
|
range. (Perfect filling!!) */
|
||||||
if (NILP (new_ranges_head))
|
if (NILP (new_ranges_head))
|
||||||
new_ranges_head = Fcons (Fcons (make_fixnum (visible_beg),
|
new_ranges_head = Fcons (Fcons (make_fixnum (BUF_BEGV (buffer)),
|
||||||
make_fixnum (visible_beg)),
|
make_fixnum (BUF_BEGV (buffer))),
|
||||||
Qnil);
|
Qnil);
|
||||||
|
|
||||||
XTS_PARSER (parser)->last_set_ranges = new_ranges_head;
|
XTS_PARSER (parser)->last_set_ranges = new_ranges_head;
|
||||||
|
|
Loading…
Add table
Reference in a new issue