-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
diff-editorfeature-requestRequest for new features or functionalityRequest for new features or functionality
Milestone
Description
When registering a code lens provider, I am unable to get the code lens to appear on an IStandaloneDiffEditor despite setting the option to show code lens to true. From debugging it appears that the provideCodeLenses function of the CodeLensProvider that I am trying to register never gets called when the DiffEditor loads.
It was not clear from the documentation that CodeLenses were even intended to be shown on the DiffEditor, however the option to show and hide CodeLens on the construction options tends to make it appear that CodeLenses are supported by the DiffEditor.
monaco-editor version: 0.20.0
Browser: Chrome 80.0.3987.149
OS: Windows 10
Playground code that reproduces the issue:
var value = [
'',
'class Example {',
'\tprivate m:number;',
'',
'\tpublic met(): string {',
'\t\treturn "Hello world!";',
'\t}',
'}'
].join('\n')
var originalModel = monaco.editor.createModel(value, 'typescript');
var modifiedModel = monaco.editor.createModel(value.replace('public', 'private'), 'typescript');
var diffEditor = monaco.editor.createDiffEditor(document.getElementById("container"), {
enableSplitViewResizing: false,
codeLens:true,
renderSideBySide: true
});
diffEditor.setModel({
original: originalModel,
modified: modifiedModel
});
var commandId = diffEditor.addCommand(0, function () {
// services available in `ctx`
alert('my command is executing!');
}, '');
monaco.languages.registerCodeLensProvider('typescript', {
provideCodeLenses: function (model, token) {
return {
lenses: [
{
range: {
startLineNumber: 2,
startColumn: 1,
endLineNumber: 3,
endColumn: 1
},
id: "First Line",
command: {
id: commandId,
title: "First Line"
}
}
]
};
},
resolveCodeLens: function (model, codeLens, token) {
return codeLens;
}
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
diff-editorfeature-requestRequest for new features or functionalityRequest for new features or functionality