Pure-D / serve-d

D LSP server (dlang language server protocol server)
MIT License
200 stars 48 forks source link

Problem with folding region #309

Closed ryuukk closed 1 year ago

ryuukk commented 1 year ago

Let's take this code:

    struct Data
    {
        int a;
    private: // <-- this messes up fold region
        int b;
    }

If you try to fold struct Data

Then it stops at private:

image

image

Expected:

It should fold the struct like this:

image

On super long code

Note:

It works fine if private: is indented more than the struct Data

image

image

It's probably a vscode issue, but i'm not sure

WebFreak001 commented 1 year ago

it seems you are on stable, where folding regions weren't implemented yet. Try again with serve-d nightly/beta

ryuukk commented 1 year ago

i'm not on stable, i'm on master with both dcd/serve-d

WebFreak001 commented 1 year ago

hm then the folding provider seems to be completely broken in that code, since the folding region indicator should be on the line with struct Data

can you share code to reproduce? This is how a simple struct reproduces here with master serve-d:

image

image

image

image

ryuukk commented 1 year ago

I reinstalled the extension just to be sure, and still same problem:

image

image

WebFreak001 commented 1 year ago

you are right, it's broken in the pre-compiled releases, might be an issue with selections / dependencies. I'll investigate.

ryuukk commented 1 year ago

image

same org maintain these dependencies, it should be all synchronized to latest version, there is no reason this stuff to be this convoluted

at best it should be same repo

WebFreak001 commented 1 year ago

I talked with Geod24 about this, the problem here is that libdparse behaves like a 1.x.y library with breaking changes decisions, but isn't released like one. Making libdparse 1.0.0 is gonna improve things here and also give users a guarantee that breaking changes will have a migration process and only break in a new major.

WebFreak001 commented 1 year ago

@ryuukk I had it reproduced and have been trying around what could be broken here, but it turned out I just accidentally downloaded stable instead of nightly. On pre-built nightly it actually works fine for me.

Can you check in the trace: verbose code-d/serve-d output log if it contains foldingRangeProvider anywhere? If that's in there, the folding should work.

It looks like the only way in code how folding could break is if the dcdext component wasn't loaded, but dcdext does not have any dependencies and should always succeed, unless it doesn't have any workspace / folder instance.

WebFreak001 commented 1 year ago

ah can reproduce it if I don't open any folder/workspace with vscode. Will fix

ryuukk commented 1 year ago
"foldingRangeProvider": {},
..
 "defaultFoldingRangeProvider": null,

Here is what i get

I also tried the latest commits, still no luck

Here is the full log:

https://gist.github.com/ryuukk/0fd8a22a5b69e41c6f987cecd4fcc8e2

ryuukk commented 1 year ago

I reported it on vscode repo: https://github.com/microsoft/vscode/issues/177688

Since it should work without the language server anyways, sublime text doesn't have this problem

image

WebFreak001 commented 1 year ago

the problem has been solved on master

ryuukk commented 1 year ago

are you sure it is solved? i just tried again with master and still same issue

To replicate:

Do you have any custom dfmt/dscanner config file that could interfere?

I'll try to investigate more, i need to check how this whole thing works first