aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYuan Fu2025-02-22 23:24:38 -0800
committerYuan Fu2025-02-23 00:08:56 -0800
commit2dbf7d0b1b26a9676fbdb56a5955f3f24f521cc4 (patch)
tree8b2c5115090ff041f8b12be01592c2489d33fbe3 /src
parent9c1d13c89a94685c0d1120d15e28bfb24e9644c3 (diff)
downloademacs-2dbf7d0b1b26a9676fbdb56a5955f3f24f521cc4.tar.gz
emacs-2dbf7d0b1b26a9676fbdb56a5955f3f24f521cc4.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/treesit.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/treesit.c b/src/treesit.c
index 655eab8af8a..f234698defd 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -1072,12 +1072,12 @@ treesit_sync_visible_region (Lisp_Object parser)
1072 ptrdiff_t beg = XFIXNUM (XCAR (range)); 1072 ptrdiff_t beg = XFIXNUM (XCAR (range));
1073 ptrdiff_t end = XFIXNUM (XCDR (range)); 1073 ptrdiff_t end = XFIXNUM (XCDR (range));
1074 1074
1075 if (end <= visible_beg) 1075 if (end <= BUF_BEGV (buffer))
1076 /* Even the end is before visible_beg, discard this range. */ 1076 /* Even the end is before BUF_BEGV (buffer), discard this range. */
1077 new_ranges_head = XCDR (new_ranges_head); 1077 new_ranges_head = XCDR (new_ranges_head);
1078 else if (beg >= visible_end) 1078 else if (beg >= BUF_ZV (buffer))
1079 { 1079 {
1080 /* Even the beg is after visible_end, discard this range and all 1080 /* Even the beg is after BUF_ZV (buffer), discard this range and all
1081 the ranges after it. */ 1081 the ranges after it. */
1082 if (NILP (prev_cons)) 1082 if (NILP (prev_cons))
1083 new_ranges_head = Qnil; 1083 new_ranges_head = Qnil;
@@ -1090,10 +1090,10 @@ treesit_sync_visible_region (Lisp_Object parser)
1090 /* At this point, the range overlaps with the visible portion of 1090 /* At this point, the range overlaps with the visible portion of
1091 the buffer in some way (in front / in back / completely 1091 the buffer in some way (in front / in back / completely
1092 encased / completely encases). */ 1092 encased / completely encases). */
1093 if (beg < visible_beg) 1093 if (beg < BUF_BEGV (buffer))
1094 XSETCAR (range, make_fixnum (visible_beg)); 1094 XSETCAR (range, make_fixnum (BUF_BEGV (buffer)));
1095 if (end > visible_end) 1095 if (end > BUF_ZV (buffer))
1096 XSETCDR (range, make_fixnum (visible_end)); 1096 XSETCDR (range, make_fixnum (BUF_ZV (buffer)));
1097 } 1097 }
1098 prev_cons = lisp_ranges; 1098 prev_cons = lisp_ranges;
1099 } 1099 }
@@ -1103,8 +1103,8 @@ treesit_sync_visible_region (Lisp_Object parser)
1103 options, so just throw the towel: just give the parser a zero 1103 options, so just throw the towel: just give the parser a zero
1104 range. (Perfect filling!!) */ 1104 range. (Perfect filling!!) */
1105 if (NILP (new_ranges_head)) 1105 if (NILP (new_ranges_head))
1106 new_ranges_head = Fcons (Fcons (make_fixnum (visible_beg), 1106 new_ranges_head = Fcons (Fcons (make_fixnum (BUF_BEGV (buffer)),
1107 make_fixnum (visible_beg)), 1107 make_fixnum (BUF_BEGV (buffer))),
1108 Qnil); 1108 Qnil);
1109 1109
1110 XTS_PARSER (parser)->last_set_ranges = new_ranges_head; 1110 XTS_PARSER (parser)->last_set_ranges = new_ranges_head;