ajaxorg / ajaxorg/ace

Range: intersects: start and end seem to be included

Offen
#5,877 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
effort/small feature-request p2
Vorherrschende Sprache
JavaScript
Sterne
27.1k
Forks
5.3k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### Describe the bug

The intersects method doesn't account for the end boundary of a range which should be excluded from the computation

### Expected Behavior

Given that r1 stops at the start boundary of r2, we expect those two ranges to not intersect.

### Current Behavior

intersects returns true in the case described

### Reproduction Steps

Given the two ranges:
``` js
r1 = new Range(0, 0, 0, 1)

r2 = new Range(0, 1, 0, 2)
r1.intersects(r2)
// true
```

### Possible Solution

Very naive, of course
```js
function intersects(r1, r2, exludeEnd=false) {
if (exludeEnd) {
r2 = {...r2, end: {...r2.end, column: r2.end.column - 1}}
}
return r1.intersects(r2)
}
```

### Additional Information/Context

_No response_

### Ace Version / Browser / OS / Keyboard layout

Ace 1.36.3 / firefox 143 /linux / azerty

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.