sebastiencs / company-box

A company front-end with icons
561 stars 64 forks source link

Doc delay at the first candidate #114

Closed seagle0128 closed 4 years ago

seagle0128 commented 4 years ago

run-with-idle-timer causes the delay of displaying doc at the first candidate. It works after moving up or down. I test with run-with-timer, and it seems working but I am not sure if there is side-effect.

https://github.com/sebastiencs/company-box/blob/20384f0e382c063173b9d863344b1b23bc1e4954/company-box-doc.el#L137

sebastiencs commented 4 years ago

Hi @seagle0128.

I'm not sure if I understand your issue, could you elaborate a bit ?

seagle0128 commented 4 years ago

Hi @seagle0128.

I'm not sure if I understand your issue, could you elaborate a bit ?

Sorry for the confusion! When displaying the candidates in company-box, the doc of the first candidate will be delayed 5 seconds to display although the it's set to 0.5s. The docs are displayed timely if moving up or down to select other candidates.

stardiviner commented 4 years ago

I can reproduce this problem. I've noticed this problem before.

seagle0128 commented 4 years ago

@stardiviner so, can u pls try this snippet and check if there is any side-effect?

(defun company-box-doc (selection frame)
  (when company-box-doc-enable
    (-some-> (frame-parameter frame 'company-box-doc-frame)
        (make-frame-invisible))
        (when (timerp company-box-doc--timer)
           (cancel-timer company-box-doc--timer))
        (setq company-box-doc--timer
           (run-with-timer
              company-box-doc-delay nil
              (lambda nil
                 (company-box-doc--show selection frame)
                 (company-ensure-emulation-alist))))))
stardiviner commented 4 years ago

Now the doc popup faster, feels same fast as other candidates on first candidate. Confirmed. Thanks for solution.

sebastiencs commented 4 years ago

Thanks for testing @stardiviner @seagle0128. I will use run-with-timer

seagle0128 commented 4 years ago

Cool~~~ Thank you! @sebastiencs

seagle0128 commented 4 years ago

@sebastiencs Any update?

sebastiencs commented 4 years ago

@seagle0128 Done

seagle0128 commented 4 years ago

@sebastiencs Thank you! It does work.

real-or-random commented 1 year ago

I needed to change it here too: https://github.com/sebastiencs/company-box/blob/766546b2668b5ef4eb4abbde632c9acd370c7788/company-box.el#L998 (which was added by PR #119 which has been opened before https://github.com/sebastiencs/company-box/commit/8f33f8189bebbce4bd7da2d0fc5d2528bc2f683c but merged afterward).

I can open PR if you like.