Skip to main content

smart_toggle_at

Function smart_toggle_at 

Source
pub fn smart_toggle_at(text: &str, cursor: usize) -> Option<(String, usize)>
Expand description

Toggle the boolean-ish token at char offset cursor to its opposite: word pairs (true/false, yes/no, …) matched as whole words with case preserved, or symbol pairs (&&/||, ==/!=, …) at/around the cursor. Returns the rewritten text and the cursor’s new offset, or None if nothing togglable is under the cursor.