When is the indent function of a mode called?


#1

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.


#2

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


#3

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


#4

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.


#5

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!


#6

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