aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-02 12:45:26 +0000
committerAleksey Kladov <[email protected]>2020-03-02 12:45:26 +0000
commit8f8980cedfc3f21b1a48b42a759796bd2d5a2dc3 (patch)
tree19f0dd3cdb134277263ff245977b0b29d3f1e3b4 /crates
parent29bdd435fcd5c120863cfef17a327fc6fc278d1c (diff)
Tighten up an assert
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs4
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