purescript-language-server icon indicating copy to clipboard operation
purescript-language-server copied to clipboard

Getting Duplicate imports after autocomplete

Open natefaubion opened this issue 5 years ago • 7 comments

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.

natefaubion avatar Sep 08 '20 17:09 natefaubion

By recently, I mean past month or so.

natefaubion avatar Sep 08 '20 17:09 natefaubion

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?)

nwolverson avatar Sep 08 '20 19:09 nwolverson

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.

natefaubion avatar Sep 08 '20 19:09 natefaubion

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

Thimoteus avatar Sep 08 '20 19:09 Thimoteus

purs version 0.13.8

Well, I'm not on the latest then 😆

natefaubion avatar Sep 08 '20 19:09 natefaubion

Example of it happening. Screen Shot 2020-09-09 at 10 36 41 AM

Still not sure what triggers it. What sort of state is maintained in the server that might influence this?

natefaubion avatar Sep 09 '20 17:09 natefaubion

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

nwolverson avatar Sep 09 '20 19:09 nwolverson