Skip to content

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