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

Multiple elm projects in Open Folder #8

Closed
allanderek opened this issue Jul 4, 2019 · 3 comments

Comments

@allanderek
Copy link

commented Jul 4, 2019

I have a project P that has two Elm sub-projects, E1 and E2. If I open the folder of the containing project P, then one of the two Elm sub-projects doesn't have symbols associated with each of the files therein.

This means that the outline does not work and Ctrl+Shift+O does not work.

Opening either sub-project as a folder itself means that all symbols are collected properly and everything works as expected.

@buinauskas

This comment has been minimized.

Copy link

commented Jul 9, 2019

The issue is caused by this line: https://github.com/elm-tooling/elm-language-server/blob/c4cda7b9694cb9b405d6cfdf598cb44340b2f8d3/src/providers/astProvider.ts#L33

    this.connection.console.info(
      `Changed text document, going to parse it. ${params.textDocument.uri}`,
    );
    const document: VersionedTextDocumentIdentifier = params.textDocument;
    let tree: Tree | undefined = this.forest.getTree(document.uri);
    if (tree === undefined) {
      const fileContent: string = readFileSync(document.uri, "utf8");
      tree = this.parser.parse(fileContent);
    }

Code attempts to read file with file:// prefix and this seems to be redundant on a Linux system and causesreadFileSync ENOENT exception that it couldn't find a file.

A very dirty solution is to string replace file:// with an empty string:

    this.connection.console.info(
      `Changed text document, going to parse it. ${params.textDocument.uri}`,
    );
    const document: VersionedTextDocumentIdentifier = params.textDocument;
    const correctPath = document.uri.replace("file://", "");
    let tree: Tree | undefined = this.forest.getTree(correctPath);
    if (tree === undefined) {
      const fileContent: string = readFileSync(correctPath, "utf8");
      tree = this.parser.parse(fileContent);
    }

While that works - it's hella crap solution. Attaching a screenshot with locally updated code with working symbols.
Screenshot from 2019-07-09 22-25-13

@Razzeee

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

@buinauskas
That was helpful for tracking it down.

We start a server for each elm project and you can attach to each one via a different port. What happend here is that server number 1 was receiving updates on server number 2's files. That seemed to cause problems and was in fact not intended.
elm-tooling/elm-language-server@1f60526 should fix that.

@Razzeee

This comment has been minimized.

Copy link
Member

commented Jul 12, 2019

Fixed in master, will be in the next release.

@Razzeee Razzeee closed this Jul 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.