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 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
5 checks passed
5 checks passed
linux
Details
windows
Details
darwin
Details
VS Code #20191119.38 succeeded
Details
license/cla All CLA requirements met.
Details
@alexdima

This comment has been minimized.

Copy link
Member

alexdima commented Nov 19, 2019

👍 Thank you!

@alexdima alexdima added this to the November 2019 milestone Nov 19, 2019
@spahnke spahnke deleted the spahnke:reference-models branch Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.