microsoft / microsoft/monaco-editor
go to definition - different model: loading via http
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
i'm adding a go to definition feature using a langserver.
monaco notices it's a new model 👍, and then tries to load it.
the ranges of the place that contains definition is correct.
does monaco support in-place replacement of the model?
what i'm seeing is that it just offers to download the whole
file containing the resulting definition, i.e., this line
window.open(data.resource.toString());.
in my monaco build:
private doOpenEditor(editor:editorCommon.ICommonCodeEditor, data:IResourceInput): IEditor {
var model = this.findModel(editor, data);
if (!model) {
if (data.resource) {
if (this.openEditorDelegate) {
this.openEditorDelegate(data.resource.toString());
return null;
} else {
var schema = data.resource.scheme;
if (schema === Schemas.http || schema === Schemas.https) {
// This is a fully qualified http or https URL
window.open(data.resource.toString());
return this.editor;
}
}
}
return null;
}
var selection = <editorCommon.IRange>data.options.selection;
if (selection) {
if (typeof selection.endLineNumber === 'number' && typeof selection.endColumn === 'number') {
editor.setSelection(selection);
editor.revealRangeInCenter(selection);
} else {
var pos = {
lineNumber: selection.startLineNumber,
column: selection.startColumn
};
editor.setPosition(pos);
editor.revealPositionInCenter(pos);
}
}
return this.editor;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with doOpenEditor in src/vs/editor/browser/standalone/simpleServices.ts, especially the handling of http and https resources when no model is found. Trace how go-to-definition supplies the resource and selection range. Done means a definition in a different HTTP-loaded model can open in place at the supplied range instead of triggering a download.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100