mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
ace2_inner: Fix efficiency of rangeForLine()
Returning `true` or `false` has no effect when iterating using
`Array.prototype.forEach`. This fixes a bug introduced in commit
b28bfe8e31
.
This commit is contained in:
parent
ca2e008e7b
commit
2d50a8aa95
1 changed files with 6 additions and 9 deletions
|
@ -2162,16 +2162,13 @@ function Ace2Inner(editorInfo, cssManagers) {
|
||||||
[-1, N + 1],
|
[-1, N + 1],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// returns index of cleanRange containing i, or -1 if none
|
||||||
const rangeForLine = (i) => {
|
const rangeForLine = (i) => {
|
||||||
// returns index of cleanRange containing i, or -1 if none
|
for (const [idx, r] of cleanRanges.entries()) {
|
||||||
let answer = -1;
|
if (i < r[0]) return -1;
|
||||||
cleanRanges.forEach((r, idx) => {
|
if (i < r[1]) return idx;
|
||||||
if (i >= r[1]) return false; // keep looking
|
}
|
||||||
if (i < r[0]) return true; // not found, stop looking
|
return -1;
|
||||||
answer = idx;
|
|
||||||
return true; // found, stop looking
|
|
||||||
});
|
|
||||||
return answer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeLineFromRange = (rng, line) => {
|
const removeLineFromRange = (rng, line) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue