monaco-editor version: 0.20.0
Browser: Chrome
OS: Windows
Reproduction steps:
-
Go to playground
-
Paste code below
-
Run
-
ctrl + MouseOver on IdentifierA in line 1
=> Identifier A is blue and underlined; small widget pops up showing reference "another IdentifierA" => OK!
-
ctrl left click on IdentifierA in line 1
=> IdentifierA in line 3 blinks and Cursor jumps to line 3 => OK!
-
ctrl + MouseOver on IdentifierB in line 2
=> Identifier B is underlined; small widget pops up showing reference "another IdentifierB" => OK!
-
ctrl left click on IdentifierB in line 2
=> Nothing happens. Editor should display model2 and Curser should jump to line 1 => Bug!
I was able to fix this bug:
a) insert
editor.setModel(model);
in standaloneCodeServiceImpl.ts after line 43
b) replace
return null;
whith
return monaco.editor.getModels().find(model => model.uri.toString() === resource.toString());
in Method StandaloneCodeEditorServiceImpl.findModel
Instead of b) it would certainly be better to use SimpleEditorModelResolverService, but i don't know how to get a reference of it so i better refrain from making a pull request on base of my amateur work.
By the way:
I'm writing an online-IDE with compiler for my students. Without monaco editor this would not be possible:
Monaco editor is an awesome library, thank you!
Editor Playground html:
<div id="container" style="height:100%;"></div>
Editor Playground css:
none
Editor Playground js:
const editor = monaco.editor.create(document.getElementById("container"), {});
const model1 = monaco.editor.createModel("identifierA\nIdentifierb\nanother IdentifierA", "python", monaco.Uri.from({
scheme: "inmemory",
path: "file1.macc",
}))
const model2 = monaco.editor.createModel("another Identifierb", "python", monaco.Uri.from({
scheme: "inmemory",
path: "file2.macc",
}))
editor.setModel(model1)
monaco.languages.registerDefinitionProvider("python", {
provideDefinition: (model, position, token) => {
if (position.lineNumber == 1) {
return {
uri: model1.uri,
range: {
startLineNumber: 3,
startColumn: 9,
endLineNumber: 3,
endColumn: 20
}
}
}
if (position.lineNumber == 2) {
return {
uri: model2.uri,
range: {
startLineNumber: 1,
startColumn: 9,
endLineNumber: 1,
endColumn: 20
}
}
}
}
});
monaco-editor version: 0.20.0
Browser: Chrome
OS: Windows
Reproduction steps:
Go to playground
Paste code below
Run
ctrl + MouseOver on IdentifierA in line 1
=> Identifier A is blue and underlined; small widget pops up showing reference "another IdentifierA" => OK!
ctrl left click on IdentifierA in line 1
=> IdentifierA in line 3 blinks and Cursor jumps to line 3 => OK!
ctrl + MouseOver on IdentifierB in line 2
=> Identifier B is underlined; small widget pops up showing reference "another IdentifierB" => OK!
ctrl left click on IdentifierB in line 2
=> Nothing happens. Editor should display model2 and Curser should jump to line 1 => Bug!
I was able to fix this bug:
a) insert
editor.setModel(model);in standaloneCodeServiceImpl.ts after line 43
b) replace
return null;whith
return monaco.editor.getModels().find(model => model.uri.toString() === resource.toString());in Method
StandaloneCodeEditorServiceImpl.findModelInstead of b) it would certainly be better to use
SimpleEditorModelResolverService, but i don't know how to get a reference of it so i better refrain from making a pull request on base of my amateur work.By the way:
I'm writing an online-IDE with compiler for my students. Without monaco editor this would not be possible:
Monaco editor is an awesome library, thank you!
Editor Playground html:
Editor Playground css:
none
Editor Playground js: