Looking for ideas here.
I’ve got a custom CodeMirror mode that has a lot of auto-indent rules. I think they work great, but occasionally someone decides to do something different, and it’s frustrating when the editor throws away the personal artistic expression in their indentation choices. So, users are requesting that I be more discerning about when to trigger auto-indent.
I’m considering these two rules:
- Only trigger “electric” indent when the current line is already it’s “smart” indentation level before the edit that triggers it. That way, if you’ve done something different, I won’t mess with it,OR:
- If you’ve made edits to the current line that change the indent, then assume you know what you’re doing and disable electric indents until your cursor leaves that line.
Currently, it looks like implementing either rule would require adding an event handler on every keystroke to track this logic and change config.electricChars
appropriately. Anyone see a better way? Is this going to cause problems if the config is changed on every key?