pub fn indent_for_new_line(
method: IndentMethod,
prev: Option<&str>,
next: Option<&str>,
unit: IndentUnit,
brackets: BracketSyntax,
) -> StringExpand description
The whitespace a newly created line should start with.
prev is the text that ends up ABOVE the new line, which differs
by the key that created it:
o/O– the nearest non-blank line. (Vim takesO’s indent from the line it pushes down, which is the line the cursor is on, so both use the same source.)<CR>– the head, i.e. the text before the cursor, not the whole line. Infoo(a, |b)the whole line is bracket-balanced while the head leaves(open; only the head gives the right answer.
None means there is nothing above, i.e. the top of the buffer.
next is the text that will follow on the new line, used only for
the closer check. Pass None for the ordinary
create-an-empty-line case; pass the tail for <CR> pressed
mid-line, where the text after the cursor moves down with it and a
leading } should dedent.
Returns the whitespace string, not a column count, because the caller splices it into an edit and the rendering (tabs vs spaces) is the unit’s business.