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

Code extension registers multiple providers for the rust-analyzer scheme #12699

Closed
lnicola opened this issue Jul 5, 2022 · 5 comments
Closed
Labels
A-vscode vscode plugin issues C-bug Category: bug E-easy E-has-instructions Issue has some instructions and pointers to code to get started good first issue S-actionable Someone could pick this issue up and work on it right now

Comments

@lnicola
Copy link
Member

lnicola commented Jul 5, 2022

From the registerTextDocumentContentProvider docs: "Only one provider can be registered per scheme".

Two of the providers appear to handle this correctly (rust-analyzer-status, rust-analyzer-memory), we should probably do the same thing in the remaining four places.

CC eclipse-theia/theia#9136 (comment)

@lnicola lnicola added good first issue E-easy A-vscode vscode plugin issues S-actionable Someone could pick this issue up and work on it right now C-bug Category: bug labels Jul 5, 2022
bors added a commit that referenced this issue Jul 6, 2022
internal: use different schemes for the custom views

Related to #12699, but doesn't fix it because we still register the providers multiple times.
bors added a commit that referenced this issue Jul 6, 2022
internal: use different schemes for the custom views

Related to #12699, but doesn't fix it because we still register the providers multiple times.
bors added a commit that referenced this issue Jul 6, 2022
internal: use different schemes for the custom views

Related to #12699, but doesn't fix it because we still register the providers multiple times.
@yongikim
Copy link

@lnicola Hello. I'm looking for a "good-first-issue" to work on. Can I work on this issue? Is it fixed by #12702?

@lnicola
Copy link
Member Author

lnicola commented Oct 10, 2022

It's not fixed yet. Originally:

  • every custom command returning (we have a couple of them) a file used the same scheme
  • every invocation of a custom command registered the same scheme again

#12702 fixed the first problem, the second still exists. To fix this you'll probably have to extract the registerTextDocumentContentProvider calls out of the commands and run them only once, the extension initialization.

@yongikim
Copy link

Thank you. I'll try it. It may take a little while because this is my first time to develop a vscode extension.

@lnicola lnicola added the E-has-instructions Issue has some instructions and pointers to code to get started label Oct 10, 2022
@yongikim
Copy link

yongikim commented Oct 11, 2022

I cannot reproduce the issue. Here are what I did to debug:

  1. Open editors/code/src/commands.ts in vscode.
  2. Add some console.logs in viewItemTree function:
export function viewItemTree(ctx: Ctx): Cmd {
    // ...

    console.log("viewitem"); // I added this line.
    ctx.pushCleanup(
        vscode.workspace.registerTextDocumentContentProvider("rust-analyzer-item-tree", tdcp)
    );

    return async () => {
        console.log("viewitem async"); // I added this line.
        // ...
    }
}
  1. Run the extension in the Extension Development Host window of the vscode and run rust-analyzer: Debug ItemTree command three times.
  2. Debug console of the original vscode window is as follows:

Screen Shot 2022-10-11 at 21 38 12

Probably I'm wrong but It appears that registerTextDocumentContentProvider is called only once at the extension initialization and when the custom command is invoked afterwards, the returned funciton by viewItemTree is called.

@lnicola
Copy link
Member Author

lnicola commented Oct 17, 2022

Yes, I think you're right. Sorry for the inconvenience :(.

@lnicola lnicola closed this as completed Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-vscode vscode plugin issues C-bug Category: bug E-easy E-has-instructions Issue has some instructions and pointers to code to get started good first issue S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

2 participants