GFM Mode doesn't seem to respect codeblock mode-specific indentation.


I’m using CodeMirror to author mixed-content documents (primarily a custom language mode embedded into markdown codeblocks). Unfortunately, when I use the custom language mode by itself, indentation works as expected, but when it’s used as a sub-mode of GFM, indentation appears to purely follow the previous line’s indentation level. The codeblock has the appropriate language identifier. All syntax highlighting still works, and the custom mode is actually working, it just isn’t in control of indentation.

The custom mode is written using the simple mode addon, and I dropped a console.log into codemirror/addon/mode/simple.js#L195 and confirmed that, when used directly the function is invoked for indentation, but when used as a submode it is not.

This is the snipped setup for the editor. All the custom-mode specific setup is in the codemirror-mode-eve module.

import * as CodeMirror from "codemirror";
import "codemirror-mode-eve";

// GFM-embedded multi-mode editing for Eve Documents.
import "codemirror/addon/mode/overlay";
import "codemirror/addon/mode/multiplex";
import "codemirror/mode/gfm/gfm";
import "codemirror/mode/markdown/markdown";

// Settings

editor.setOption("keyMap", "emacs");

editor.setOption("tabSize", 2);
editor.setOption("indentUnit", 2);
editor.setOption("autoClearEmptyLines", true);
editor.setOption("smartIndent", true);
editor.setOption("electricChars", true);
editor.setOption("mode", "gfm");

Is there anything obviously wrong with my setup? If not I’d be happy to move this to GitHub issues and provide any additional diagnostic information that might be useful.


This patch might help with that


That does indeed fix the problem. Do you have a rough estimate of when a package including this patch will be available on NPM? I tried depending directly on the GitHub repository, but it seems the package.json isn’t set up to auto-build. Everything works fine if I subsequently npm install in the codemirror directory.

Aside: This is the fourth or fifth time you’ve speedily resolved my off-in-the-weeds problem. I’ve subscribed on patreon as a small effort to say thanks for the stellar level of support.


I do monthly releases, around the 20th of each month, so it’ll be a few weeks until the next one.