Skip to content

Commit 6fb6c81

Browse files
authored
lsp-headerline: make mouse-2 action for symbol to toggle narrowing (#2227)
1 parent b2905ac commit 6fb6c81

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lsp-headerline.el

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,17 @@ Switch to current mouse interacting window before doing BODY."
174174
(lsp-headerline--go-to-symbol symbol)))
175175
(define-key map [header-line mouse-2]
176176
(lsp-headerline--make-mouse-handler
177-
(lsp-headerline--narrow-to-symbol symbol)))
177+
(-let (((&DocumentSymbol :range (&RangeToPoint :start :end)) symbol))
178+
(if (and (eq (point-min) start) (eq (point-max) end))
179+
(widen)
180+
(lsp-headerline--narrow-to-symbol symbol)))))
178181
map)
179-
(format "mouse-1: go to '%s' symbol\nmouse-2: narrow to '%s' range" name name)
182+
(format "mouse-1: go to '%s' symbol\nmouse-2: %s"
183+
name
184+
(-let (((&DocumentSymbol :range (&RangeToPoint :start :end)) symbol))
185+
(if (and (eq (point-min) start) (eq (point-max) end))
186+
"widen"
187+
(format "narrow to '%s' range" name))))
180188
symbol-display-string))
181189

182190
(defun lsp-headerline--path-up-to-project-root (root-path path)

0 commit comments

Comments
 (0)