mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 01:38:13 +00:00
Merge #3395
3395: Tighten up an assert r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
f40ed3fcb0
1 changed files with 4 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue