aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYuan Fu2024-01-30 22:18:33 -0800
committerYuan Fu2024-01-30 22:28:47 -0800
commitf63bcf2dfeb26de511f468adc237e6ea8a3cb6cc (patch)
treef8e96198d175504d715e195e67ba07cf06833545 /src
parentdd177b7b88c81ab71e1d5a97b872d85d524fee9b (diff)
downloademacs-f63bcf2dfeb26de511f468adc237e6ea8a3cb6cc.tar.gz
emacs-f63bcf2dfeb26de511f468adc237e6ea8a3cb6cc.zip
Fix treesit--indent-1 regarding local parsers
Take this code as an example: 1 class Foo 2 { 3 /** 4 * Block comment 5 */ 6 function foo($c) { 7 } 8 } Suppose the block comment is covered by a local parser. When we indent line 3, treesit--indent-1 will try to get the local parser at the BOL, and it'll get the local parser. But it shouldn't use the local parser to indent this line, it should use the host parser of that local parser instead. So now, if treesit--indent-1 gets a local parser, but the local parser's root node's start coincides with BOL, treesit--indent-1 will use the host parser to indent this line. We also need to make treesit--update-ranges-local to save the host parser along with the local parser, and make treesit-local-parsers-at/on extract and return the host parser. I also switch the two cases in the cond form in treesit--indent-1: (null (treesit-parser-list)) and (car local-parsers), (car local-parsers) now takes precedence. * lisp/treesit.el (treesit-local-parsers-at): (treesit-local-parsers-on): Add WITH-HOST parameter. (treesit--update-ranges-local): Save the host parser to the local overlay. (treesit--indent-1): If the root node of the local parser is at BOL, use the host parser instead.
Diffstat (limited to 'src')
0 files changed, 0 insertions, 0 deletions