File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -424,15 +424,15 @@ category/group nodes are traversed without becoming part of that name."
424424
425425(defun ai-code--imenu-symbol-header-at-position (position )
426426 " Return the best declaration header available at POSITION.
427- Use the existing semantic scope helper, which is Tree-sitter-backed when the
428- major mode has an active parser. Fall back to the source line so Imenu-only
429- modes still get a useful annotation."
427+ When Tree-sitter is active, use the existing semantic scope helper for a
428+ precise declaration header. Otherwise return the source line."
430429 (when-let* ((pos (ai-code--imenu-symbol-position-number position))
431430 ((<= (point-min ) pos))
432431 ((<= pos (point-max ))))
433432 (save-excursion
434433 (goto-char pos)
435- (let ((scope (ignore-errors (ai-code--current-scope-context pos))))
434+ (let ((scope (when (ai-code--treesit-available-p)
435+ (ignore-errors (ai-code--current-scope-context pos)))))
436436 (or (plist-get scope :function-header )
437437 (plist-get scope :class-header )
438438 (string-trim
You can’t perform that action at this time.
0 commit comments