diff options
author | Igor Aleksanov <[email protected]> | 2020-10-08 07:30:01 +0100 |
---|---|---|
committer | Igor Aleksanov <[email protected]> | 2020-10-12 09:32:22 +0100 |
commit | 991d0190968662f23220d8aefaf28bd03b1dbe41 (patch) | |
tree | c666f206bff7707a1f3a92340a23c28c84a7cbb3 /crates/ide/src | |
parent | fb0ab9f7456018ff0bac628e05366f976c5af1a7 (diff) |
Use TextRange::contains_inclusive in fixes check
Diffstat (limited to 'crates/ide/src')
-rw-r--r-- | crates/ide/src/diagnostics.rs | 6 | ||||
-rw-r--r-- | crates/ide/src/diagnostics/fixes.rs | 3 |
2 files changed, 4 insertions, 5 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index add102ff2..b30cdb6ed 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -257,8 +257,7 @@ mod tests { | |||
257 | 257 | ||
258 | assert_eq_text!(&after, &actual); | 258 | assert_eq_text!(&after, &actual); |
259 | assert!( | 259 | assert!( |
260 | fix.fix_trigger_range.start() <= file_position.offset | 260 | fix.fix_trigger_range.contains_inclusive(file_position.offset), |
261 | && fix.fix_trigger_range.end() >= file_position.offset, | ||
262 | "diagnostic fix range {:?} does not touch cursor position {:?}", | 261 | "diagnostic fix range {:?} does not touch cursor position {:?}", |
263 | fix.fix_trigger_range, | 262 | fix.fix_trigger_range, |
264 | file_position.offset | 263 | file_position.offset |
@@ -288,8 +287,7 @@ mod tests { | |||
288 | 287 | ||
289 | assert_eq_text!(&after, &actual); | 288 | assert_eq_text!(&after, &actual); |
290 | assert!( | 289 | assert!( |
291 | fix.fix_trigger_range.start() <= file_position.offset | 290 | fix.fix_trigger_range.contains_inclusive(file_position.offset), |
292 | && fix.fix_trigger_range.end() >= file_position.offset, | ||
293 | "diagnostic fix range {:?} does not touch cursor position {:?}", | 291 | "diagnostic fix range {:?} does not touch cursor position {:?}", |
294 | fix.fix_trigger_range, | 292 | fix.fix_trigger_range, |
295 | file_position.offset | 293 | file_position.offset |
diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index b47fe0469..0c75e50b0 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs | |||
@@ -111,7 +111,8 @@ impl DiagnosticWithFix for IncorrectCase { | |||
111 | let offset = name_node.syntax().text_range().start(); | 111 | let offset = name_node.syntax().text_range().start(); |
112 | let file_position = FilePosition { file_id, offset }; | 112 | let file_position = FilePosition { file_id, offset }; |
113 | 113 | ||
114 | let rename_changes = rename_with_semantics(sema, file_position, &self.suggested_text)?; | 114 | let rename_changes = |
115 | rename_with_semantics(sema, file_position, &self.suggested_text).ok()?; | ||
115 | 116 | ||
116 | let label = format!("Rename to {}", self.suggested_text); | 117 | let label = format!("Rename to {}", self.suggested_text); |
117 | Some(Fix::new(&label, rename_changes.info, rename_changes.range)) | 118 | Some(Fix::new(&label, rename_changes.info, rename_changes.range)) |