Skip to content

Commit 537dbad

Browse files
committed
limit semantic enrichment to treesit
1 parent 8a436a3 commit 537dbad

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

ai-code-input.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)