diff options
author | Aleksey Kladov <[email protected]> | 2020-03-02 12:45:26 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-03-02 12:45:26 +0000 |
commit | 8f8980cedfc3f21b1a48b42a759796bd2d5a2dc3 (patch) | |
tree | 19f0dd3cdb134277263ff245977b0b29d3f1e3b4 | |
parent | 29bdd435fcd5c120863cfef17a327fc6fc278d1c (diff) |
Tighten up an assert
-rw-r--r-- | crates/rust-analyzer/src/main_loop/handlers.rs | 4 |
1 files changed, 4 insertions, 0 deletions
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( | |||
184 | // `text.char_at(position) == typed_char`. | 184 | // `text.char_at(position) == typed_char`. |
185 | position.offset -= TextUnit::of_char('.'); | 185 | position.offset -= TextUnit::of_char('.'); |
186 | let char_typed = params.ch.chars().next().unwrap_or('\0'); | 186 | let char_typed = params.ch.chars().next().unwrap_or('\0'); |
187 | assert!({ | ||
188 | let text = world.analysis().file_text(position.file_id)?; | ||
189 | text[position.offset.to_usize()..].starts_with(char_typed) | ||
190 | }); | ||
187 | 191 | ||
188 | // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, | 192 | // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, |
189 | // but it requires precise cursor positioning to work, and one can't | 193 | // but it requires precise cursor positioning to work, and one can't |