emacs-lsp / lsp-ui

UI integrations for lsp-mode
https://emacs-lsp.github.io/lsp-ui
GNU General Public License v3.0
1.04k stars 141 forks source link

Don't re-draw hints if the text is the same #434

Closed ColemanGariety closed 4 years ago

ColemanGariety commented 4 years ago

Describe the bug Right now, the hints are re-drawn every time the cursor moves. This results in everything constantly flickering as you move around.

Even if performance were perfect, there's no need to replace already drawn text with exactly the same text. Can we do a simple equality check before drawing?

yyoncho commented 4 years ago

Can you provide a bit more info on what hints you are referring to? lsp-mode + package extension have 10+ different hints.

ColemanGariety commented 4 years ago

I only have experience with the code action and linting hints. They appear to "flicker" because they are added and removed when you move the cursor.

yyoncho commented 4 years ago

Can you post a screenshot? My guess is that you are referring to lsp-ui-sideline.

ColemanGariety commented 4 years ago

These are from typescript language server. I am using emacs 27 compiled with json serialization, if that helps.

I am referring to both "remove declaration for 'setFieldValue'" and "'setFieldValue' is declared but never read."

EDIT: but not the type description in the minibuffer.

hints

ColemanGariety commented 4 years ago

On second though, it isn't necessary to check whether the string is same. All that's needed is to prevent the hint from updating until the next hint (or lack thereof) is ready.

sebastiencs commented 4 years ago

@JacksonGariety Would this config solves your issue ?

(setq lsp-ui-sideline-update-mode 'line)
yyoncho commented 4 years ago
(setq lsp-ui-sideline-update-mode 'line)

Using this will break the code actions because a lot of them are available only on a specific position.

sebastiencs commented 4 years ago

@yyoncho Ah, I see

sebastiencs commented 4 years ago

@yyoncho does it concern only code actions ? Or hover informations too ?

I see that hover informations are not affected by lsp-ui-sideline-update-mode, but we still make the same requests and replace the sidelines when moving the point left or right on the same line.

Would it make sense to not refresh those hover datas (not code actions), even with lsp-ui-sideline-update-mode set to 'point ? Is the current method for getting the symbol positions ((bounds-of-thing-at-point 'symbol)) correct ? Are we missing some data by not sending the point position instead ?

yyoncho commented 4 years ago

Would it make sense to not refresh those hover datas (not code actions), even with lsp-ui-sideline-update-mode set to 'point ?

Yes. The symbol data has to be updated only if there is a change of line/change of content of the line.

Is the current method for getting the symbol positions ((bounds-of-thing-at-point 'symbol)) correct ?

I think it is the best thing that we can do. Technically, symbol-at-point is less precise than the server notion of a symbol.

Are we missing some data by not sending the point position instead ?

Can you elaborate? I think that we are sending the position.

sebastiencs commented 4 years ago

Can you elaborate? I think that we are sending the position.

Thanks, I think you answered my question with your 2nd answer