Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual annoyance: Hover is switching between "pages" #78

Open
rogermartensson opened this issue Mar 6, 2020 · 5 comments
Open

Visual annoyance: Hover is switching between "pages" #78

rogermartensson opened this issue Mar 6, 2020 · 5 comments

Comments

@rogermartensson
Copy link

Not sure how I should describe this. Please change subject to something better.
I do like my hover but this is pretty annoying. I hope you can find a way to make it stop. :)

here is a GIF showing what is happening.

hoverissue

@TysonAndre
Copy link
Owner

TysonAndre commented Mar 6, 2020

You may need to disable hover from other extensions - A shorter one without @param is provided by Phan - the one I see in the screenshot doesn't look like Phan.

To disable hover from phan, set phan.enableHover to false.

This is also a known problem when phan.analyzedProjectDirectory is an array with more than one project. I'm not sure how to fix that in vscode, but if you figure out how, let me know.

It's also possible that vs code is flickering because Phan's taking too long to generate hover text, causing vs code to start new requests, kill the language server, etc. Right now, Phan does a full analysis so it can properly generate hover text for $x->someMethod()

@TysonAndre
Copy link
Owner

See #70 - I haven't been able to figure out how to resolve this in the language client library I'm using, but external contributions are welcome.

What's the value of phan.analyzedProjectDirectory you're using?

@rogermartensson
Copy link
Author

analyzedProjectDirectory is an array to multiple directories.

I did some testing with editor.hover.delay and when I reached about 3 seconds (3000 ms) the "flickering" stopped. So you might be on to something there with your thought about "taking too long". But I think a hover delay of 3 seconds is way too long. :-)

It's like it keeps redrawing the Hover over and over again, even if everything that should be shown is there.

Maybe there is a way for the server to signal a "Phan is checking..." message to the client so it gets a quick response and when Phan has a message to show it can update the Hover? That type of "flicker"/update is more understandable.

@TysonAndre
Copy link
Owner

Related to phan/phan#3252

analyzedProjectDirectory is an array to multiple directories.

The fact that there are multiple directories is the cause of it, I assume the 3 seconds working is just a timing coincidence and may change in the future.

Speeding up Phan's hover response may very well just make the flickering faster.

The actual problem is that Phan is sending hover requests to both servers. I think the other server would respond with null in that case, but I'm not 100% sure.

https://code.visualstudio.com/api/references/vscode-api#RelativePattern

I wasn't initially able to figure out how to limit hover suggestions to the workspace corresponding to a given Phan folder, but it looks like I can use a RelativePattern (to the phan project directory) in a DocumentSelector to do that.

https://github.com/microsoft/vscode-languageserver-node/blob/master/client/src/client.ts mentions it's using that for registerHoverProvider, and other things - https://code.visualstudio.com/api/references/document-selector

	protected registerLanguageProvider(options: HoverRegistrationOptions): [Disposable, HoverProvider] {
		const provider: HoverProvider = {
			provideHover: (document, position, token) => {
				const client = this._client;
				const provideHover: ProvideHoverSignature = (document, position, token) => {
					return client.sendRequest(HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then(
						client.protocol2CodeConverter.asHover,
						(error) => {
							client.logFailedRequest(HoverRequest.type, error);
							return Promise.resolve(null);
						}
					);
				};
				const middleware = client.clientOptions.middleware!;
				return middleware.provideHover
					? middleware.provideHover(document, position, token, provideHover)
					: provideHover(document, position, token);
			}
		};
		return [Languages.registerHoverProvider(options.documentSelector!, provider), provider];

@TysonAndre
Copy link
Owner

See documentSelectors in https://github.com/TysonAndre/vscode-php-phan/blob/master/src/extension.ts , if anyone wants to try to fix this. It might take me a few days to have time to implement and test this

TysonAndre added a commit that referenced this issue Mar 29, 2020
Possible fix for #78 and #70

This should help avoid flickering in hover text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants