auto-indent in simple mode

Hi there,

TL;DR: Does the closing token of an indent block get dedented automatically? Or does it require a Shift-Tab?

I’m implementing a simple mode for Elixir, but I’m confused by the auto-deindent behaviour.
If I type def foo do and then a newline, the indentation increases by one, as expected.

But if I try to close the block, which in Elixir is done with end, the end token doesn’t get deindented, as I would expect:

def foo(a) do

I know I can trigger a reindentation of the whole file with Shift-Tab, but is there a way to make it happen automatically? Or is it a problem with my mode?

For now I resorted to a hack: a button that triggers indentAuto.

Is anybody able to answer my original question?

The simple mode in question is here by the way.

I think you can fix this by adding an electricInput property to the mode object (by adding it to the meta object in the simplemode definition). Something like electricInput: /^\s*end$/.

1 Like