我正在尝试使用Monaco作为自定义语言的编辑器。
我在playground中使用以下代码展示示例错误(省略部分内容):
const editor = monaco.editor.create(<omitted>);
const model = editor.getModel();
model.onDidChangeContent(event => {
const value = model.getValue();
const errors = GetErrors(value); // Implementation of GetErrors() not shown here
monaco.editor.setModelMarkers(model, "Example", errors);
});
这将在编辑器中产生所需的错误:
如何使快速修复选项出现?(而不是“无可用快速修复”)
我已经查看了monaco.languages.registerCodeActionProvider()
,但我不知道它如何与错误检测代码相关联。
更一般地说,我很难找到使用Monaco实现快速修复的示例。
edits: [{...}]
更改为edit: {}
,如 https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.codeaction.html 中所述。 - mwagedit: { edits: [{ edit: {...
。 - PAX