How to make some text in the TextEditor uneditable?


I’d like to be able to “freeze” some text in the TextEditor element so that it becomes uneditable, undeletable, but still selectable and syntax-highlighted.

Is there some kind of quick way to do it? Some method perhaps which I have overlooked.

If not, then it probably can be done with the events such as onDidChange. But it only gives a chance to call a certain callback, how can I prevent the change from happening in a particular region of the text?


You can set the TextEditor as readonly. See the 1.24 blog post to learn more.


No, what I want is to make a part of the text uneditable, so that the TextEditor can still accept new input, but some particluar text cannot be removed or modified