Skip to main content

is_electric_trigger

Function is_electric_trigger 

Source
pub fn is_electric_trigger(lang: Lang, line_head: &str, typed: char) -> bool
Expand description

Whether typing typed at the end of line_head should re-indent the current line.

Two triggers, matching the two ways a language closes a block:

  • typed is a bracket closer and nothing but whitespace precedes it on the line. The “nothing but whitespace” part matters — a } at the end of let x = Foo { a }; must not re-indent the line.
  • line_head + typed completes a dedent keyword that begins the line. Checked as a whole word so end fires but append and defenders do not.