Skip to content

Commit 61d7437

Browse files
fix(web): Fix "Ranges must be added sorted by from position and startSide" by having codemirror sort for us (#743)
1 parent 78a0322 commit 61d7437

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111
- Fixed issue with filtering on generic git repo indexed from http/https [#742](https://github.com/sourcebot-dev/sourcebot/pull/742)
12+
- Fixed "Ranges must be added sorted by `from` position and `startSide`" error when browsing certain files. [#743](https://github.com/sourcebot-dev/sourcebot/pull/743)
1213

1314
## [4.10.10] - 2026-01-16
1415

packages/web/src/app/[domain]/browse/[...path]/components/rangeHighlightingExtension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ export const rangeHighlightingExtension = (range: BrowseHighlightRange) => State
2525
decorations.push(markDecoration.range(from, to));
2626
}
2727

28-
return Decoration.set(decorations);
28+
return Decoration.set(decorations, /* sort = */ true);
2929
} else {
3030
const decorations: Range<Decoration>[] = [];
3131
for (let line = start.lineNumber; line <= end.lineNumber; line++) {
3232
decorations.push(lineDecoration.range(state.doc.line(line).from));
3333
}
3434

35-
return Decoration.set(decorations);
35+
return Decoration.set(decorations, /* sort = */ true);
3636
}
3737
},
3838
update(deco, tr) {

packages/web/src/ee/features/codeNav/components/symbolHoverPopup/symbolHoverTargetsExtension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const symbolHoverTargetsExtension = StateField.define<DecorationSet>({
7474
}
7575
},
7676
});
77-
return Decoration.set(decorations);
77+
return Decoration.set(decorations, /* sort = */ true);
7878
},
7979
update(deco, tr) {
8080
return deco.map(tr.changes);

packages/web/src/features/chat/components/chatThread/codeFoldingExtension.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,7 @@ const createDecorations = (state: EditorState, foldingState: FoldingState): Deco
342342
decorations.push(decoration.range(from, to));
343343
});
344344

345-
// Sort decorations by their 'from' position to ensure proper ordering
346-
decorations.sort((a, b) => a.from - b.from);
347-
348-
return Decoration.set(decorations);
345+
return Decoration.set(decorations, /* sort = */ true);
349346
};
350347

351348
// Combined StateField that manages both folding state and decorations

packages/web/src/features/chat/components/chatThread/referencedFileSourceListItem.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ const ReferencedFileSourceListItem = ({
156156
}
157157
}
158158

159-
decorations.sort((a, b) => a.from - b.from);
160-
return Decoration.set(decorations);
159+
return Decoration.set(decorations, /* sort = */ true);
161160
},
162161
update(deco, tr) {
163162
return deco.map(tr.changes);

packages/web/src/lib/extensions/searchResultHighlightExtension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const matchHighlighter = StateField.define<DecorationSet>({
4141
})
4242
.filter((decoration) => decoration !== undefined);
4343

44-
highlights = Decoration.set(decorations)
44+
highlights = Decoration.set(decorations, /* sort = */ true);
4545
}
4646
}
4747

0 commit comments

Comments
 (0)