Hiding the leading and trailing characters of the entire doc

Hi, I need to hide the leading and trailing characters of the entire doc.

In this string:

() => ({
	a: true,
	b: new Date()
})

I want to hide the surroundings of an object - () => ( and ), and get this result:

{
	a: true,
	b: new Date()
}

But for some reason the closing parenthesis of the Date is hidden if there aren’t any characters in front of it:

{
	a: true,
	b: new Date(
}

Please tell me what am I doing wrong. A minimal demo.

The regexp is matched per line, so your code will hide any paren at the end of a line. You’ll probably have to build up the decorations yourself, not use MatchDecorator.

I am new to codemirror, could you please direct me to what I need to learn to create such a decorator?

This example goes through some way to use decorations. I’d guess your plugin would just look at the first and last line in the document and decide which ranges to hide based on their content.

I see, thanks for such quick replies.