-
Notifications
You must be signed in to change notification settings - Fork 4k
Open
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Monaco Editor Playground Code
monaco.languages.register({ id: 'myLanguage' });
monaco.editor.onDidCreateModel(function(model) {
function validate() {
var textToValidate = model.getValue();
var markers = [{
severity: monaco.MarkerSeverity.Error,
startLineNumber: 1,
startColumn: 3,
endLineNumber: 1,
endColumn: 5,
message: 'Lets correct it'
}];
monaco.editor.setModelMarkers(model, 'myLanguage', markers);
}
var handle = null;
model.onDidChangeContent(() => {
// debounce
clearTimeout(handle);
handle = setTimeout(() => validate(), 500);
});
validate();
});
monaco.languages.registerCodeActionProvider("myLanguage", {
provideCodeActions: (model, _range, context, _token) => {
const actions = context.markers.map(error => {
return {
title: `My quickfix`, // Name of quickfix
diagnostics: [error],
kind: "quickfix",
edit: {
edits: [
{
resource: model.uri,
edit: {
range: error,
text: "replacement text" // text to replace with
}
}
]
},
isPreferred: true
};
});
return {
actions: actions,
dispose: () => {}
}
}
});
var ed = monaco.editor.create(document.getElementById("container"), {
value: "cont foo = 1;",
language: "myLanguage",
lightbulb: { enabled: monaco.editor.ShowLightbulbIconMode.OnCode },
});Reproduction Steps
No response
Actual (Problematic) Behavior
No response
Expected Behavior
No response
Additional Context
throwing error on provideCodeActions()
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels