Skip to content

Commit 8f8980c

Browse files
committed
Tighten up an assert
1 parent 29bdd43 commit 8f8980c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/rust-analyzer/src/main_loop/handlers.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ pub fn handle_on_type_formatting(
184184
// `text.char_at(position) == typed_char`.
185185
position.offset -= TextUnit::of_char('.');
186186
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+
});
187191

188192
// We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`,
189193
// but it requires precise cursor positioning to work, and one can't

0 commit comments

Comments
 (0)