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

monaco-editor: Find model by resource in SimpleEditorModelResolverService #85129

Merged
merged 1 commit into from
Nov 19, 2019

Conversation

spahnke
Copy link
Contributor

@spahnke spahnke commented Nov 19, 2019

This PR fixes microsoft/monaco-editor#935

Currently, if you run the following code in the Monaco Playground and use "Peek Definition", or "Peek References" on the method next() in line 3, you get the error "Model not found" on the browser console. This is because the SimpleEditorModelResolverService only takes into account the currently attached model. This PR instead searches through all models.

const lib = `declare class Facts {
	/**
	 * Returns the next fact
	 *
	 * [Online documentation](http://www.google.de)
	 */
	static next(): string;
}`;

const uri = monaco.Uri.file("filename/facts.d.ts");
monaco.languages.typescript.javascriptDefaults.addExtraLib(lib, uri.toString());
monaco.editor.createModel(lib, "typescript", uri);

monaco.editor.create(document.getElementById("container"), {
    value: `class Chuck {
    greet() {
        return Facts.next();
    }
}`,
    language: "javascript"
});

Thanks!

@alexdima alexdima merged commit 7d9069b into microsoft:master Nov 19, 2019
@alexdima
Copy link
Member

👍 Thank you!

@alexdima alexdima added this to the November 2019 milestone Nov 19, 2019
@spahnke spahnke deleted the reference-models branch November 20, 2019 06:47
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Peek reference and preview definition don't work across models
2 participants