make typing infra slightly more extensible

This commit is contained in:
Aleksey Kladov 2019-10-25 11:19:26 +03:00
parent 518f99e16b
commit 8d2fd59cfb
3 changed files with 74 additions and 54 deletions

View file

@ -144,12 +144,8 @@ pub fn handle_on_type_formatting(
// in `ra_ide_api`, the `on_type` invariant is that
// `text.char_at(position) == typed_char`.
position.offset = position.offset - TextUnit::of_char('.');
let edit = match params.ch.as_str() {
"=" => world.analysis().on_eq_typed(position),
"." => world.analysis().on_dot_typed(position),
_ => return Ok(None),
}?;
let char_typed = params.ch.chars().next().unwrap_or('\0');
let edit = world.analysis().on_char_typed(position, char_typed)?;
let mut edit = match edit {
Some(it) => it,
None => return Ok(None),