Skip to content

Commit befb3cf

Browse files
tigersoldierMaskRay
authored andcommitted
lsp-ui-doc: Do not return child frame if it's deleted. (#173)
Since the window in the child frame is a dedicated window, it can be killed when the buffer is killed, resulting in the child frame being deleted. When this happens, lsp-ui-doc will prevent users from switching to other windows because the advice on `select-window' fails on operating on the dead frame. Since there can be other edge cases that may delete the child frame without notifying lsp-ui-doc, I feel that the most robust solution is always check the liveness of the child frame before returning it to callers.
1 parent bd5970e commit befb3cf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lsp-ui-doc.el

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ Because some variables are buffer local.")
181181
"Set the frame parameter ‘lsp-ui-doc-frame’ to FRAME."
182182
`(set-frame-parameter nil 'lsp-ui-doc-frame ,frame))
183183

184-
(defmacro lsp-ui-doc--get-frame ()
184+
(defun lsp-ui-doc--get-frame (&optional include-deleted-frame)
185185
"Return the child frame."
186-
`(frame-parameter nil 'lsp-ui-doc-frame))
186+
(let ((frame (frame-parameter nil 'lsp-ui-doc-frame)))
187+
(and (frame-live-p frame) frame)))
187188

188189
(defun lsp-ui-doc--make-buffer-name ()
189190
"Construct the buffer name, it should be unique for each frame."
@@ -563,7 +564,7 @@ HEIGHT is the documentation number of lines."
563564
(lsp-ui-doc--render-buffer string symbol)
564565
(if (lsp-ui-doc--inline-p)
565566
(lsp-ui-doc--inline)
566-
(unless (frame-live-p (lsp-ui-doc--get-frame))
567+
(unless (lsp-ui-doc--get-frame)
567568
(lsp-ui-doc--set-frame (lsp-ui-doc--make-frame)))
568569
(lsp-ui-doc--move-frame (lsp-ui-doc--get-frame))
569570
(unless (frame-visible-p (lsp-ui-doc--get-frame))

0 commit comments

Comments
 (0)