-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] Duplicated function in intellisense after addExtraLib
#3580
Comments
addExtraLib
It would be awesome if you could investigate this bug! Here is our guide how to debug the language support of the monaco editor: |
I also have this bug! |
Hey @hediet , trying to fix this bug and I'm running into issues with the instructions: #4383 |
I found the source of this bug! The function at getOrCreateModel at https://github.com/microsoft/monaco-editor/blob/main/src/language/typescript/languageFeatures.ts#L116 is being called when the editor tries to autocomplete the function that's in This can be fixed by returning null always on getOrCreateModel (seems to have no negative consequences, everything still works). Alternatively, you can create a model to store the extralib content which also fixes this bug: const filename = "importedlibs.d.ts";
const a = monaco.editor.createModel(
`declare module '@test/math' {
export function myFunFunction(a: number, b: number): number
}`,
"typescript",
monaco.Uri.file(filename)
);
const disposable = monaco.languages.typescript.typescriptDefaults.addExtraLib(
a.getValue(),
monaco.Uri.file(filename).toString()
); Given that using |
@Shaddix , I think #4544 fixes this issue, but it seems like we need some more community approvals to continue. Could you look and test that PR? Also, @Jaxkr if you wanted to look, I think the change in #4544 works in a similar way to what you are suggesting. I think that your proposed fix of never creating a model here doesn't fix the case where a model for the extra lib is legitimately opened, such as when a user "peeks" the definition. |
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Link
https://microsoft.github.io/monaco-editor/playground.html?source=v0.35.0#XQAAAAI_AgAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw0ujCMH_KmaUY-oS3CKMkOSajRHzMOh275SgQndWdGyFPATHN_jQG5rOFPT-L8kRd7Az7STn-1YydGSUXwZb8WhGo0LTm9LMOTHHaW-VuaVSEvOtnVqiQcdHtSbJ-MXc4sDBPYRWn9llPd7wkQFMjP-1wIbhnirKgcQ6QYJQWrxfa5BkiuTVNdyljIo8gJsjLpnqDCMW2vX2xR9_7xYNQp_SXP3TiWFimDIX7MBNCCrUtv7Nd9PsGeM7tIg-NcKx52fdfiUJveVPjdykEcohN41wWUrSv8oYLJ8Af0x3ExQXC2m0G-b9UaPGF7dlYR039F7NJ9lOEbgZxN7ctjDPUEqzsRJxEzrYKPxox8liDi33QpT9c_SyopAHM4Fb3JbbAibxH5CF4N0IYWmqkV5veef-yegA-hf7_oC_zRsjSABnU_ySaVgA
Monaco Editor Playground Code
Reproduction Steps
hover over
trim
function in Preview pane.Tooltip will be shown: 'function trim(s: string): string (+1 overload)'
(+1 overload) is not expected (since I only defined a single
trim
function).Similar thing happens if I type
trim(
to see autocompletion. It shows like there are 2 overloads oftrim
function, while actually there's only one.Actual (Problematic) Behavior
editor behaves like
addExtraLib
is called twice and shows 2 identical overloads of a function defined inaddExtraLib
Expected Behavior
I'd expect a single overload of
trim
function to exist in autocomplete.Additional Context
No response
The text was updated successfully, but these errors were encountered: