Fix treesit_sync_visible_region's range fixup code (bug#73264)
authorYuan Fu <casouri@gmail.com>
Sun, 15 Sep 2024 07:24:03 +0000 (00:24 -0700)
committerYuan Fu <casouri@gmail.com>
Sun, 15 Sep 2024 07:31:40 +0000 (00:31 -0700)
commit460b9d705ab482003fabe75b0fd1df223abe467c
treefa25d65ea42a6e5f48f7a5a32d5b95fb6e265fae
parent81347c1aaf25b27e78e8beee4bc818ad2c4e1b71
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.
src/treesit.c
test/src/treesit-tests.el