When is the indent function of a mode called?

I am reading though mode/javascript/javascript.js and trying to understand indentation. At what point in execution is the indent function of a mode called? I have not been able to find it in the source code.

1 Like

When the indentation for the line is needed, i.e. when executing newlineAndIndent or indentAuto or calling indentLine.

Is a copy of the tokenizer state saved at the end of each line?

Not at the end of every line, but at the end of some lines, and such a state can be rolled forward by running the mode over the intermediate text.

Which src file contains the logic to determine when to save state and which to initiate a reparse?

Also, thanks for the help Marijn. You are an awesome maintainer!

src/line/highlight.js contains most of the state management logic. The indentation code is in src/input/indent.js.