|
1 | 1 | use std::{collections::VecDeque, ops::RangeInclusive};
|
2 | 2 |
|
3 | 3 | use rowan::TextRange;
|
4 |
| -use rustc_hash::{FxHashMap, FxHashSet}; |
| 4 | +use rustc_hash::FxHashMap; |
5 | 5 |
|
6 | 6 | use crate::{
|
7 |
| - syntax_editor::{mapping::MissingMapping, Change, ChangeKind, Position, PositionRepr}, |
| 7 | + syntax_editor::{mapping::MissingMapping, Change, ChangeKind, PositionRepr}, |
8 | 8 | SyntaxElement, SyntaxNode, SyntaxNodePtr,
|
9 | 9 | };
|
10 | 10 |
|
@@ -41,12 +41,17 @@ pub(super) fn apply_edits(editor: SyntaxEditor) -> SyntaxEdit {
|
41 | 41 | .then(a.change_kind().cmp(&b.change_kind()))
|
42 | 42 | });
|
43 | 43 |
|
44 |
| - let disjoint_replaces_ranges = changes.iter().zip(changes.iter().skip(1)).all(|(l, r)| { |
45 |
| - l.change_kind() == ChangeKind::Replace |
46 |
| - && r.change_kind() == ChangeKind::Replace |
47 |
| - && (l.target_parent() != r.target_parent() |
| 44 | + let disjoint_replaces_ranges = changes |
| 45 | + .iter() |
| 46 | + .zip(changes.iter().skip(1)) |
| 47 | + .filter(|(l, r)| { |
| 48 | + // We only care about checking for disjoint replace ranges |
| 49 | + l.change_kind() == ChangeKind::Replace && r.change_kind() == ChangeKind::Replace |
| 50 | + }) |
| 51 | + .all(|(l, r)| { |
| 52 | + (l.target_parent() != r.target_parent() |
48 | 53 | || l.target_range().intersect(r.target_range()).is_none())
|
49 |
| - }); |
| 54 | + }); |
50 | 55 |
|
51 | 56 | if stdx::never!(
|
52 | 57 | !disjoint_replaces_ranges,
|
|
0 commit comments