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

Module name codelens suggestion always present (with flickering) #1769

Closed
azuzunaga opened this issue Apr 23, 2021 · 13 comments · Fixed by #3570
Closed

Module name codelens suggestion always present (with flickering) #1769

azuzunaga opened this issue Apr 23, 2021 · 13 comments · Fixed by #3570
Assignees
Labels
component: hls-module-name-plugin type: support User support tickets, questions, help with setup etc.

Comments

@azuzunaga
Copy link

The codelens hint at the top of the editor always suggests a module name if the existing module name doesn't match the dir/filename structure. However, the hint collapses and is displayed again while typing, making the editor scroll up and down the screen.

Is there a way to turn module name hints off? It is possible to disable all codelens hints via the settings, but I'd like to preserve the other hints.

Here is a screen recording demonstrating the jumping around:

demo-hint-jump

@azuzunaga azuzunaga changed the title Module name suggestion always present Module name codelens suggestion always present Apr 23, 2021
@jneira jneira transferred this issue from haskell/vscode-haskell Apr 24, 2021
@jneira jneira added component: plugins type: support User support tickets, questions, help with setup etc. labels Apr 24, 2021
@jneira
Copy link
Member

jneira commented Apr 24, 2021

Hi thanks for opening the issue. There is a way to disable plugins but it still is not documented (#1433). To disable the module name plugin you can add the following json snippet where your editor put the lsp configuration (in vscode .vscode/settings.js)

haskell.plugin.moduleName.globalOn": false

@jneira jneira added the status: needs info Not actionable, because there's missing information label Apr 24, 2021
@ndmitchell
Copy link
Collaborator

@jneira this sounds like a bug in the module plugin though. I'm not totally sure why it wants to rename the module (seems dubious to me), but it should definitely not flicker as the code goes in/out of parsing, but should be using the last stale correct value to base its suggestions on.

@jneira
Copy link
Member

jneira commented Apr 24, 2021

yeah, you are right, the code lens should be stable

@azuzunaga
Copy link
Author

@jneira, thanks for the quick response! Adding the setting did the trick. Appreciate the help.

@Ailrun Ailrun added the type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. label Apr 24, 2021
@jneira jneira changed the title Module name codelens suggestion always present Module name codelens suggestion always present (with flickering) Apr 24, 2021
@jneira jneira removed the status: needs info Not actionable, because there's missing information label Apr 24, 2021
@jneira
Copy link
Member

jneira commented Apr 24, 2021

@azuzunaga thank you for trying and confirming it works, i am gonna let this open to track the solution of the disturbing flickering

@jneira
Copy link
Member

jneira commented Jan 31, 2022

maybe @tittoassini could have some time to take a quick look 🙂

@tittoassini
Copy link
Contributor

The code seems to have changed significantly since I wrote the initial version so I might not be the right person to ask.

Anyway I had a quick look and the problem is what @ndmitchell suggested, as the code become unparsable the code lens disappears.

@tittoassini
Copy link
Contributor

It might be just a matter of changing this line:

141 pm <- MaybeT . runAction "ModuleName.GetParsedModule" state $ use GetParsedModule nfp

to

141 pm <- MaybeT . runAction "ModuleName.GetParsedModule" state $ useWithStale GetParsedModule nfp

I will have a look soon.

@tittoassini
Copy link
Contributor

Yes, that solves the problem.

Of course if we use stale information, that might lead to incorrect code actions.

If for example:

  • you edit the file causing a syntax error
  • module is now unparsable but the plugin will still display its previous suggestion (say "Set module name to X") before an incorrect "module Y where"
  • insert, say, an empty line before "module Y where"
  • click on the "Set module name to X" code lens, the change is applied on the previous position of "module Y where" :-)

But that's life for you (btw this happens with all plugins that rely on stale info, for example the 'imports' one).

@tittoassini
Copy link
Contributor

So what you want? What you really really want?

Correctness or Aesthetics?

Can't have both I am afraid (or maybe you can? any suggestion?)

@jneira
Copy link
Member

jneira commented Jan 31, 2022

Hmm both if possible :-)
But i doesnt seem so serious even if the worst case you described, user clicks the code lens and it is inserted, their bad :-P

@tittoassini
Copy link
Contributor

I see that useWithStale returns a PositionMapping, is that meant to be used in conjunction with a diff to update the position of a code lens edit? that would fix the problem (a minimal problem for sure, possibly not worth fixing).

I am far from my computer for a few days, I will look into this again next sunday, in the meantime any suggestion is welcome.

@michaelpj
Copy link
Collaborator

The recommendation here still seems good, just need someone to implement.

@michaelpj michaelpj removed the type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. label Mar 22, 2023
@July541 July541 self-assigned this Apr 16, 2023
@mergify mergify bot closed this as completed in #3570 Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-module-name-plugin type: support User support tickets, questions, help with setup etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants