-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Peek definition fails on tokens coming from different models. #852
Comments
After some more work, I got a working peek definition and go to definition. For reference, here is my implementation of the overrides: const getOverrides = actions => (e: HTMLElement) => ({
editorService: {
openEditor: function(input, sideBySide): Promise<any> {
// this actually sets the opened source
actions.set({ opened: input.resource.path })
// this just returns the editor itself
return Promise.resolve({ getControl: () => getEditor(e) })
},
resolveEditor: function() {
// I still don't know when/if this is used, I assume it is never called in my case
return Promise.resolve({})
}
},
textModelService: {
createModelReference(
uri: monaco.Uri
): Promise<IReference<ITextEditorModel>> {
const model: ITextEditorModel = {
load() {
return Promise.resolve(model)
},
// in my case, I have nothing to dispose as I just re-use existing resources
dispose() {},
textEditorModel: getModel(uri.path)
}
return Promise.resolve({
object: model,
// in my case, I have nothing to dispose as I just re-use existing resources
dispose() {}
})
}
}
}) |
@Mytrill Nice work! Where do I get the |
As of Monaco Editor 0.14, it seems that the Unfortunately when overriding only this function, I get |
Hi @alexandrudima, any idea for #852 (comment)? |
@ulrichb There was a refactoring -- microsoft/vscode@cf77b6e -- which resulted in the merging/folding of the |
I found that I can import the services like this, so I don't have to implement all methods: import { StaticServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices';
const codeEditorService = StaticServices.codeEditorService.get(); |
@satya164 This was a great hint. I now mutate the Thanks! |
monaco-editor version: 0.12.0
Browser: any (tested with Chrome and Firefox)
OS: mac OS
Code:
On the
index.js
model, the "Peek Definition" action on thevalue
variable throws an exception:Stacktrace:
For reference, I managed to get the "Go To Definition" working by overriding the
editorService
but that did not solve this issue.Is there another service I should override or something I should do differently?
EDIT: for reference, I found which service I had to override
textModelService.createModelReference(uri)
:It seems the types are slightly different in VS code source and in
monaco-editor
(for exampleIReference
orITextEditorModel
are not inmonaco-editor
), is there a consistent way to translate themonaco-editor
equivalent of the VS code types in order for me to know exactly what I have to implement?Thank you,
Anthony
The text was updated successfully, but these errors were encountered: