Fix treesit_sync_visible_region's range fixup code (bug#73264)
new_ranges_head
|
v
( )->( )->( )->( )->( )
^ ^
| |
| lisp_ranges (loop head)
|
prev_cons -> set cdr to nil to cut of the rest
result:
( )->( )
* src/treesit.c (treesit_sync_visible_region): Cut off this cons and the
rest, not set the current range's end to nil.
* test/src/treesit-tests.el:
(treesit-range-fixup-after-edit): Add tests for all cases.
This commit is contained in:
@@ -709,7 +709,37 @@ visible_end.)"
|
||||
'((1 . 7) (10 . 15))))
|
||||
(narrow-to-region 5 13)
|
||||
(should (equal (treesit-parser-included-ranges parser)
|
||||
'((5 . 7) (10 . 13)))))))
|
||||
'((5 . 7) (10 . 13))))
|
||||
|
||||
;; Narrow in front.
|
||||
(widen)
|
||||
(treesit-parser-set-included-ranges parser '((4 . 17)))
|
||||
;; 11111111111111111111
|
||||
;; [ ]
|
||||
;; { } narrow
|
||||
(narrow-to-region 1 8)
|
||||
(should (equal (treesit-parser-included-ranges parser)
|
||||
'((4 . 8))))
|
||||
|
||||
;; Narrow in back.
|
||||
(widen)
|
||||
(treesit-parser-set-included-ranges parser '((4 . 17)))
|
||||
;; 11111111111111111111
|
||||
;; [ ]
|
||||
;; { } narrow
|
||||
(narrow-to-region 15 20)
|
||||
(should (equal (treesit-parser-included-ranges parser)
|
||||
'((15 . 17))))
|
||||
|
||||
;; No overlap
|
||||
(widen)
|
||||
(treesit-parser-set-included-ranges parser '((15 . 20)))
|
||||
;; 11111111111111111111
|
||||
;; [ ]
|
||||
;; { } narrow
|
||||
(narrow-to-region 1 10)
|
||||
(should (equal (treesit-parser-included-ranges parser)
|
||||
nil)))))
|
||||
|
||||
;;; Multiple language
|
||||
|
||||
|
||||
Reference in New Issue
Block a user