gpt4 book ai didi

javascript - Ace Editor setAnnotations 方法一次仅显示一个错误

转载 作者:行者123 更新时间:2023-12-03 11:00:15 26 4
gpt4 key购买 nike

我当前正在运行一个外部插件,它可以检测 ace 编辑器选项卡中的代码气味,并且我想使用 setAnnotations 来迭代行号和错误消息数组以突出显示所有错误。但是,只有数组中的最后一个对象被突出显示,这表明一旦设置了第二个注释,前一个注释就会被删除。

function highlightError(errorMsg, line){
editor.getSession().setAnnotations([{
row: line-1,
column: 10,
text: errorMsg,
type: "error" // also warning and information
}]);

}

这是我用来做到这一点的方法。

提前谢谢您。

最佳答案

setAnnotations 接受注释数组,它会替换之前调用的注释,因此您需要将所有注释收集到数组中,然后调用 setAnnotations 一次

关于javascript - Ace Editor setAnnotations 方法一次仅显示一个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28131998/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com