purescript-language-server
purescript-language-server copied to clipboard
Getting Duplicate imports after autocomplete
I haven't narrowed down an exact reproducible case, but I've been getting a lot of duplicate qualified imports on autocomplete lately. At first I thought it related to whether the document was saved or not, but it often works OK (no duplicates) even without saving.
By recently, I mean past month or so.
By duplicate you mean you get the same import line twice?
Given the imports are coming from purs ide, I guess either you're getting bad answers from that or the edit is being screwed up as it is applied
(I'm not seeing this, can anyone else confirm?)
Yes, I mean duplicate qualified imports, like
import Data.Map as Map
import Data.Map as Map
The reason I didn't suspect purs ide specifically is because we've been on a fixed version of it for a while (which is admittedly not the latest), but I'm not aware of any changes to ide import at the purs level.
I'm seeing it too, but not sure how to reproduce. If you want system info:
VSCode version 1.48.2 macOS Catalina version 10.15.6 PureScript IDE version 0.21.4 purs version 0.13.8
purs version 0.13.8
Well, I'm not on the latest then 😆
Example of it happening.

Still not sure what triggers it. What sort of state is maintained in the server that might influence this?
There's no language-server state per se that might be relevant (there is a LS-side model of the document, not our code, I'd be very surprised if that was relevant). Obvious candidates are the IDE server which does the actual import rewriting, or (most likely) the edit that we reflect that back to the editor. I made a change to the edits that we send a little while back as in fact we'd been violating the LSP spec for a long time which was causing problems in other clients. I'd imagine we have some sort of off by one in the edit we're computing.
There's not really enough information there to form an example for me - what were the steps to cause that to happen? ie what did you actually autocomplete, what did you expect to happen to the imports. I'd hazard a guess that you twice completed something on that first line and duplicated the 2nd, ie the last line below the expected edit?
If you could set purescript.trace.server to "verbose" and find the text edit that we send for the imports, that should have the relvant info. Sadly I still can't repro