Skip to content

go to definition - different model: loading via http #291

Open
@mbana

Description

@mbana

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());.


https://github.com/Microsoft/vscode/blob/0d6a9f8389cd044851ac994e527969bd53d2d387/src/vs/editor/browser/standalone/simpleServices.ts#L134

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;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions