Bug 1894659 - [devtools] Fix duplicate breakpoints on really long lines r=devtools-reviewers,nchevobbe

`visibleRanges` can return multiple ranges (mostly for large sources the overflow the current viewport),
and those might contain the same line, causing duplicates.
Switching from cm.visibleRanges to cm.viewport

Differential Revision: https://phabricator.services.mozilla.com/D209233
This commit is contained in:
Hubert Boma Manilla 2024-05-07 00:04:16 +00:00
parent 395589a0ca
commit 281aa6bac0

View file

@ -933,8 +933,9 @@ class Editor extends EventEmitter {
// (representing the lines in the current viewport) and generate a new rangeset for updating the line gutter
// based on the conditions defined in the markers(for each line) provided.
const builder = new RangeSetBuilder();
for (const { from, to } of cm.visibleRanges) {
for (let pos = from; pos <= to; ) {
const { from, to } = cm.viewport;
let pos = from;
while (pos <= to) {
const line = cm.state.doc.lineAt(pos);
for (const {
lineClassName,
@ -958,7 +959,6 @@ class Editor extends EventEmitter {
}
pos = line.to + 1;
}
}
// To update the state with the newly generated marker range set, a dispatch is called on the view
// with an transaction effect created by the lineNumberMarkersCompartment, which is used to update the