fix locIntersect
This commit is contained in:
parent
0ee947e8a6
commit
7a7928f466
@ -259,21 +259,19 @@ pub fn convertRangeEncoding(text: []const u8, range: types.Range, from_encoding:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if a and b intersect
|
/// returns true if a and b intersect
|
||||||
pub fn locIntersect(a: Loc, b: Loc) bool {
|
pub fn locIntersect(a: Loc, b: Loc) bool {
|
||||||
std.debug.assert(a.start <= a.end and b.start <= b.end);
|
std.debug.assert(a.start <= a.end and b.start <= b.end);
|
||||||
const a_start_in_b = b.start <= a.start and a.start <= b.end;
|
return a.start < b.end and a.end > b.start;
|
||||||
const a_end_in_b = b.start <= a.end and a.end <= b.end;
|
|
||||||
return a_start_in_b or a_end_in_b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if a is inside b
|
/// returns true if a is inside b
|
||||||
pub fn locInside(inner: Loc, outer: Loc) bool {
|
pub fn locInside(inner: Loc, outer: Loc) bool {
|
||||||
std.debug.assert(inner.start <= inner.end and outer.start <= outer.end);
|
std.debug.assert(inner.start <= inner.end and outer.start <= outer.end);
|
||||||
return outer.start <= inner.start and inner.end <= outer.end;
|
return outer.start <= inner.start and inner.end <= outer.end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the union of a and b
|
/// returns the union of a and b
|
||||||
pub fn locMerge(a: Loc, b: Loc) Loc {
|
pub fn locMerge(a: Loc, b: Loc) Loc {
|
||||||
std.debug.assert(a.start <= a.end and b.start <= b.end);
|
std.debug.assert(a.start <= a.end and b.start <= b.end);
|
||||||
return .{
|
return .{
|
||||||
|
Loading…
Reference in New Issue
Block a user