From 15d976142c3ce9d670f54d8b8be9143af57ef42f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 15 Oct 2020 16:33:40 -0400 Subject: [PATCH] Fix #4000: company-box breaks if frames are deleted Company-box doesn't perform frame-live-p checks before trying to use its childframes, so any operation that cleans up the current session (like `SPC TAB x`) would break it. Should be fixed upstream. --- modules/completion/company/config.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index 7265480c0..0f724b9f4 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -127,7 +127,20 @@ https://github.com/sebastiencs/company-box/issues/44" :around #'company-box--update-scrollbar (letf! ((#'display-buffer-in-side-window #'ignore)) - (apply orig-fn args)))) + (apply orig-fn args))) + + ;; `company-box' performs insufficient frame-live-p checks. Any command that + ;; "cleans up the session" will break company-box. + ;; TODO Fix this upstream. + (defadvice! +company-box-detect-deleted-frame-a (frame) + :filter-return #'company-box--get-frame + (if (frame-live-p frame) frame)) + (defadvice! +company-box-detect-deleted-doc-frame-a (_selection frame) + :before #'company-box-doc + (and company-box-doc-enable + (frame-local-getq company-box-doc-frame frame) + (not (frame-live-p (frame-local-getq company-box-doc-frame frame))) + (frame-local-setq company-box-doc-frame nil frame)))) (use-package! company-dict