aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-02 12:46:20 +0000
committerGitHub <[email protected]>2020-03-02 12:46:20 +0000
commitf40ed3fcb037885e0111fc3da6ba5b9eb0bef2b4 (patch)
tree19f0dd3cdb134277263ff245977b0b29d3f1e3b4 /crates
parent29bdd435fcd5c120863cfef17a327fc6fc278d1c (diff)
parent8f8980cedfc3f21b1a48b42a759796bd2d5a2dc3 (diff)
Merge #3395
3395: Tighten up an assert r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
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