Having issues with matchbrackets.js on CodeMirror v3.0

Our group is currently trying to move from Codemirror v2.23 to v3.0. I noticed that matchbrackets is a separate add-on file now. So when I tried to include the add-on file I’m getting errors such as the following.

Unable to set value of the property ‘matchBrackets’: object is null or undefined

the error is being raised here:

CodeMirror.defineOption("matchBrackets", false, function (cm, val, old)
	{
		if (old && old != CodeMirror.Init)
			cm.off("cursorActivity", doMatchBrackets);
		if (val)
		{
			cm.state.matchBrackets = typeof val == "object" ? val : {};
			cm.on("cursorActivity", doMatchBrackets);
		}
	});

Am I using the wrong version of matchbrackets.js? I think so because state is not defined explicitly in codemirror.js v3.0

Why on earth are you moving v3.0? That’s about three years out of date by now.

And yes, mixing and matching addons from other versions is likely to break.

We tried moving directly to the latest version of CodeMirror which ended up breaking a lot of different features in our editor. So now we’re thinking of upgrading in steps.

How would you propose we do the upgrade?

Also, I’m assuming there is a version of matchbrackets.js that would be compatible with Codemirror v3. Where is it?

Read through the upgrading guides: 2.1, 3.0, 4.0.

In the zip file for 3.0, of course.

Thanks! That seems to have fixed the issue. We’ll read through the upgrading guides.