How to highlight a specific line in the ACE editor?

I am using the ACE editor for my site. I need to select / highlight a specific line in the editor. But when it’s big code, the ACE editor shows some errors, for example, when it scrolls line numbers and the highlight line number is different from the one I want to highlight. I searched and found this problem . But in fact, I can’t understand this. Can someone give an example for highlighting a line in the ACE editor? Here is my current code:

var aceLines = document.getElementsByClassName("ace_line");
var gutters = document.getElementsByClassName("ace_gutter-cell");
var gutLineNo = parseInt(gutters[0].innerHTML)-1;

if(count1 != 0){
        aceLines[arNum[count]-gutLineNo].style.backgroundColor = "green";
        aceLines[arNum[count1]-gutLineNo].style.backgroundColor = "black";

    }else{
        aceLines[arNum[count]-gutLineNo].style.backgroundColor = "green";
    }
+4
source share
1 answer

dom. Ace dom- setMarker, Ace?

css,

.myMarker {
  position:absolute;
  background:rgba(100,200,100,0.5);
  z-index:20
}

var Range = ace.require('ace/range').Range;
editor.session.addMarker(new Range(from, 0, to, 1), "myMarker", "fullLine");

from to - , .

+6

Source: https://habr.com/ru/post/1568030/


All Articles