From 8f8980cedfc3f21b1a48b42a759796bd2d5a2dc3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Mar 2020 13:45:26 +0100 Subject: Tighten up an assert --- crates/rust-analyzer/src/main_loop/handlers.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates') diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index 6f517760f..f51263f22 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs @@ -184,6 +184,10 @@ pub fn handle_on_type_formatting( // `text.char_at(position) == typed_char`. position.offset -= TextUnit::of_char('.'); let char_typed = params.ch.chars().next().unwrap_or('\0'); + assert!({ + let text = world.analysis().file_text(position.file_id)?; + text[position.offset.to_usize()..].starts_with(char_typed) + }); // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, // but it requires precise cursor positioning to work, and one can't -- cgit v1.2.3