vscode-haskell icon indicating copy to clipboard operation
vscode-haskell copied to clipboard

Add "ignore standalone" option that disables HLS for files that don't belong to any folder

Open zkbpkp opened this issue 4 years ago • 3 comments

Addresses issue #300

How to test:

Set "Haskell: Ignore Standalone" option to true

image

Open Haskell project and check that there's only one HLS instance:

image

Create a new standalone file (Ctrl+N) and paste some Haskell code from your project. Check that the number of haskell* processes is the same (i.e. extension haven't spawned any additional processes for this standalone file)

zkbpkp avatar Feb 25 '21 21:02 zkbpkp

@KolesnichenkoDS hi, thanks for the pr, what would be the behaviour if you open directly a haskell file that does not belong to any project (with code MyStandloneModule.hs f. e.)?

jneira avatar Mar 09 '21 09:03 jneira

@jneira hi, sorry, missed the response

It will do nothing, i.e. won't start a HLS instance.

zkbpkp avatar Apr 01 '21 16:04 zkbpkp

I see how that may be a problem since you'll be forced to open the folder instead of simply opening the file. Maybe could work around that by checking (in activateServerForFolder) if there is any opened folder, if so — then ignore files that don't belong to the folder, otherwise spawn HLS as usual. Also, the option can be enabled per project, in that case if you do code Foo.hs then the option would not be enabled and HLS would spawn. The thing is, right now spawning HLS for standalone files while working on project often causes problems if you often open scratch files with some snippets (for example I do that for snippets to paste into repl after :r). Would be probably better to fix those problems (like HLS instance remaining after standalone file is closed, or duplicated of hints on project files when 2+ instances are spawned) but even then I personally would prefer to have this option since I really don't need it's functionality on scratch files and that allows to reduce memory consumption by limiting HLS to only one instance.

zkbpkp avatar Apr 01 '21 16:04 zkbpkp