mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 09:14:18 +00:00
Add text property 'imenu-region' for Eglot and 'M-x imenu' (bug#79980)
* lisp/imenu.el (imenu--flatten-index-alist) (imenu--parentify-index-alist, imenu-choose-buffer-index): Use the text property 'imenu-region' instead of 'breadcrumb-region'. * lisp/progmodes/eglot.el (eglot--imenu-SymbolInformation) (eglot--imenu-DocumentSymbol): Add new text properties 'imenu-region' and 'imenu-kind' while keeping the old text properties 'breadcrumb-region' and 'breadcrumb-kind' for backward-compatibility.
This commit is contained in:
parent
864712f10b
commit
2e42cc4b30
2 changed files with 11 additions and 3 deletions
|
|
@ -866,7 +866,7 @@ Returns t for rescan and otherwise an element or subelement of INDEX-ALIST."
|
|||
(t
|
||||
(let ((subalist (imenu--flatten-index-alist
|
||||
pos concat-names new-prefix))
|
||||
(region (get-text-property 0 'breadcrumb-region name)))
|
||||
(region (get-text-property 0 'imenu-region name)))
|
||||
(if region
|
||||
;; Add non-leaf nodes with Eglot text properties.
|
||||
(append (imenu--flatten-index-alist
|
||||
|
|
@ -887,7 +887,7 @@ Returns t for rescan and otherwise an element or subelement of INDEX-ALIST."
|
|||
(list item))
|
||||
(t
|
||||
(let ((subalist (imenu--parentify-index-alist pos))
|
||||
(region (get-text-property 0 'breadcrumb-region name)))
|
||||
(region (get-text-property 0 'imenu-region name)))
|
||||
(when region
|
||||
(setq subalist (append (list (cons ".." (car region))) subalist)))
|
||||
(list (cons name subalist)))))))
|
||||
|
|
@ -928,7 +928,7 @@ The returned value is of the form (INDEX-NAME . INDEX-POSITION)."
|
|||
((when-let* ((alist (if (eq (car index-alist) imenu--rescan-item)
|
||||
(cdr index-alist) index-alist))
|
||||
(name (caar alist)))
|
||||
(get-text-property 0 'breadcrumb-region name))
|
||||
(get-text-property 0 'imenu-region name))
|
||||
;; Change the menu structure by adding ".." to non-leaf nodes
|
||||
;; only when the first node has Eglot text properties.
|
||||
(setq index-alist (imenu--parentify-index-alist index-alist))))
|
||||
|
|
|
|||
|
|
@ -3966,6 +3966,10 @@ for which LSP on-type-formatting should be requested."
|
|||
(plist-get location :range)))
|
||||
(kind (alist-get kind eglot--symbol-kind-names)))
|
||||
(cons (propertize name
|
||||
'imenu-region reg
|
||||
'imenu-kind kind
|
||||
;; Backward-compatible props
|
||||
;; to be removed later:
|
||||
'breadcrumb-region reg
|
||||
'breadcrumb-kind kind)
|
||||
(car reg))))
|
||||
|
|
@ -3981,6 +3985,10 @@ for which LSP on-type-formatting should be requested."
|
|||
(let* ((reg (eglot-range-region range))
|
||||
(kind (alist-get kind eglot--symbol-kind-names))
|
||||
(name (propertize name
|
||||
'imenu-region reg
|
||||
'imenu-kind kind
|
||||
;; Backward-compatible props
|
||||
;; to be removed later:
|
||||
'breadcrumb-region reg
|
||||
'breadcrumb-kind kind)))
|
||||
(if (seq-empty-p children)
|
||||
|
|
|
|||
Loading…
Reference in a new issue