Question: How to highlight code lines?
Symbolk opened this issue · 1 comments
I learn from README that we can get the editor instance through onEditorMount
or getEditor()
, then call APIs listed in https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandalonecodeeditor.html to implement features like jump to a line or colorize lines.
I found that if APIs like editor.revealLineInCenter(line)
is called inside onEditorMount
, it is not working, right? So I call API like revealLine()
through the instance returned by getEditor()
. But I have difficulty at highlighting code lines, I keep googling and found the API colorizeModelLine()
that maybe useful but find little examples about its usage, can you give me a hint?
I have posted a related question at: microsoft/monaco-editor#1529, looking forward to answers.
I have managed to solve it by myself:
{
range: new monaco.Range(
conflictBlock.right_start,
0,
conflictBlock.right_end,
0
),
options: {
isWholeLine: true,
className: 'rightLineDecoration',
marginClassName: 'rightLineDecoration'
}
}