mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 22:24:14 +00:00
fix insert ranges not being excluded from disjointness
This commit is contained in:
parent
21bb04d3a6
commit
5fe518361e
1 changed files with 12 additions and 7 deletions
|
@ -1,10 +1,10 @@
|
||||||
use std::{collections::VecDeque, ops::RangeInclusive};
|
use std::{collections::VecDeque, ops::RangeInclusive};
|
||||||
|
|
||||||
use rowan::TextRange;
|
use rowan::TextRange;
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
syntax_editor::{mapping::MissingMapping, Change, ChangeKind, Position, PositionRepr},
|
syntax_editor::{mapping::MissingMapping, Change, ChangeKind, PositionRepr},
|
||||||
SyntaxElement, SyntaxNode, SyntaxNodePtr,
|
SyntaxElement, SyntaxNode, SyntaxNodePtr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,10 +41,15 @@ pub(super) fn apply_edits(editor: SyntaxEditor) -> SyntaxEdit {
|
||||||
.then(a.change_kind().cmp(&b.change_kind()))
|
.then(a.change_kind().cmp(&b.change_kind()))
|
||||||
});
|
});
|
||||||
|
|
||||||
let disjoint_replaces_ranges = changes.iter().zip(changes.iter().skip(1)).all(|(l, r)| {
|
let disjoint_replaces_ranges = changes
|
||||||
l.change_kind() == ChangeKind::Replace
|
.iter()
|
||||||
&& r.change_kind() == ChangeKind::Replace
|
.zip(changes.iter().skip(1))
|
||||||
&& (l.target_parent() != r.target_parent()
|
.filter(|(l, r)| {
|
||||||
|
// We only care about checking for disjoint replace ranges
|
||||||
|
l.change_kind() == ChangeKind::Replace && r.change_kind() == ChangeKind::Replace
|
||||||
|
})
|
||||||
|
.all(|(l, r)| {
|
||||||
|
(l.target_parent() != r.target_parent()
|
||||||
|| l.target_range().intersect(r.target_range()).is_none())
|
|| l.target_range().intersect(r.target_range()).is_none())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue