diff --git a/lisp/treesit.el b/lisp/treesit.el index 5cef42ef454..7fa7df08194 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -3810,7 +3810,7 @@ the current line if the beginning of the defun is indented." Return the first non-nil evaluation of BODY. \(fn (SYM VAL) &rest BODY)" - (declare (indent 1)) + (declare (indent 1) (debug ((symbolp form) body))) (let ((result-sym (gensym)) (val-sym (gensym)) (sym (car sym-val)) diff --git a/src/treesit.c b/src/treesit.c index 7fb11048d18..84103473387 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -4259,9 +4259,13 @@ treesit_cursor_helper_1 (TSTreeCursor *cursor, TSNode *target, return true; /* ts_tree_cursor_goto_first_child_for_byte is significantly faster, - so despite it having problems (see bug#60127), we try it - first. */ - if (ts_tree_cursor_goto_first_child_for_byte (cursor, start_pos) == -1 + so despite it having problems (see bug#60127), we try it first. + Also, ts_tree_cursor_goto_first_child_for_byte can't find + zero-width nodes (which exists and are legit, e.g., markdown's + block_continuation), because a zero-width node can't contain a pos + (end > pos). */ + if (start_pos != end_pos + && ts_tree_cursor_goto_first_child_for_byte (cursor, start_pos) == -1 && !ts_tree_cursor_goto_first_child (cursor)) return false;