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

[Bug] Models with "@" in their name don't work correctly (codefixes) #3236

Closed
1 of 2 tasks
YousefED opened this issue Aug 9, 2022 · 1 comment · Fixed by #3392 · May be fixed by mofux/monaco-editor#1
Closed
1 of 2 tasks

[Bug] Models with "@" in their name don't work correctly (codefixes) #3236

YousefED opened this issue Aug 9, 2022 · 1 comment · Fixed by #3392 · May be fixed by mofux/monaco-editor#1
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities

Comments

@YousefED
Copy link

YousefED commented Aug 9, 2022

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Code

const uri = monaco.Uri.parse('file:///hello/@test.ts');
const model = monaco.editor.createModel("export let data: string = 4;", 'typescript', uri);
editor = monaco.editor.create(document.getElementById('container'), { model });

Reproduction Steps

Paste code in playground

Actual (Problematic) Behavior

The expected warning for "export let data: string = 4;" doesn't show up ("can't assign number to string")

Expected Behavior

Show the codefix warning

Additional Context

There was a related issue fixed in #3057 (#2295). However, I suspect it fixes the issue at the wrong level.

The demo shows that code fixes and possibly other functionality as well still don't work for models with an "@" (or other would-be-encoded characters) in their path.

In the case of code fixes, you can see it goes wrong in the function getSourceFileByPath:

function getSourceFileByPath(path) {
      return filesByName.get(path) || void 0;
    }

filesByName contains the files without escaped characters, but the "path" passed in from provideCodeActions is based on resource.toString(), which would return an encoded version of the Uri.

I suspect this issue affects more code paths than just for code completions, and maybe a decision should be made on whether to always call resource.toString(true) (skipEncoding) for all calls to model.uri.toString?

@hediet hediet added bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities labels Aug 9, 2022
@hediet
Copy link
Member

hediet commented Aug 9, 2022

always call resource.toString(true) (skipEncoding) for all calls to model.uri.toString?

This is already just a hack. File path -> uri was never intended to be a bijective map...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities
Projects
None yet
2 participants