diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/treesit.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/treesit.c b/src/treesit.c index 9958d8a4c2a..628a4dff9cc 100644 --- a/src/treesit.c +++ b/src/treesit.c | |||
| @@ -1064,6 +1064,7 @@ treesit_sync_visible_region (Lisp_Object parser) | |||
| 1064 | if (NILP (lisp_ranges)) return; | 1064 | if (NILP (lisp_ranges)) return; |
| 1065 | 1065 | ||
| 1066 | Lisp_Object new_ranges_head = lisp_ranges; | 1066 | Lisp_Object new_ranges_head = lisp_ranges; |
| 1067 | Lisp_Object prev_cons = Qnil; | ||
| 1067 | 1068 | ||
| 1068 | FOR_EACH_TAIL_SAFE (lisp_ranges) | 1069 | FOR_EACH_TAIL_SAFE (lisp_ranges) |
| 1069 | { | 1070 | { |
| @@ -1076,9 +1077,12 @@ treesit_sync_visible_region (Lisp_Object parser) | |||
| 1076 | new_ranges_head = XCDR (new_ranges_head); | 1077 | new_ranges_head = XCDR (new_ranges_head); |
| 1077 | else if (beg >= visible_end) | 1078 | else if (beg >= visible_end) |
| 1078 | { | 1079 | { |
| 1079 | /* Even the beg is after visible_end, dicard this range and all | 1080 | /* Even the beg is after visible_end, discard this range and all |
| 1080 | the ranges after it. */ | 1081 | the ranges after it. */ |
| 1081 | XSETCDR (range, Qnil); | 1082 | if (NILP (prev_cons)) |
| 1083 | new_ranges_head = Qnil; | ||
| 1084 | else | ||
| 1085 | XSETCDR (prev_cons, Qnil); | ||
| 1082 | break; | 1086 | break; |
| 1083 | } | 1087 | } |
| 1084 | else | 1088 | else |
| @@ -1091,12 +1095,18 @@ treesit_sync_visible_region (Lisp_Object parser) | |||
| 1091 | if (end > visible_end) | 1095 | if (end > visible_end) |
| 1092 | XSETCDR (range, make_fixnum (visible_end)); | 1096 | XSETCDR (range, make_fixnum (visible_end)); |
| 1093 | } | 1097 | } |
| 1098 | prev_cons = lisp_ranges; | ||
| 1094 | } | 1099 | } |
| 1095 | 1100 | ||
| 1096 | XTS_PARSER (parser)->last_set_ranges = new_ranges_head; | 1101 | XTS_PARSER (parser)->last_set_ranges = new_ranges_head; |
| 1097 | 1102 | ||
| 1098 | if (NILP (new_ranges_head)) | 1103 | if (NILP (new_ranges_head)) |
| 1099 | { | 1104 | { |
| 1105 | /* We are in a weird situation here: none of the previous ranges | ||
| 1106 | overlaps with the new visible region. We don't have any good | ||
| 1107 | options, so just throw the towel: just remove ranges and hope | ||
| 1108 | lisp world will soon update with reasonable ranges or just | ||
| 1109 | delete this parser. */ | ||
| 1100 | bool success; | 1110 | bool success; |
| 1101 | success = ts_parser_set_included_ranges (XTS_PARSER (parser)->parser, | 1111 | success = ts_parser_set_included_ranges (XTS_PARSER (parser)->parser, |
| 1102 | NULL, 0); | 1112 | NULL, 0); |