Skip to content

Commit 8a9cdfd

Browse files
fix: Fix "Mark decorations may not be empty" issue (#325)
1 parent 3b36ffa commit 8a9cdfd

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Fixed
11-
- Fixed issue where new oauth providers weren't being display in the login page
11+
- Fixed issue where new oauth providers weren't being display in the login page. [commit](https://github.com/sourcebot-dev/sourcebot/commit/a2e06266dbe5e5ad4c2c3f730c73d64edecedcf7)
12+
- Fixed client side "mark decorations may not be empty" error when viewing certain files. [#325](https://github.com/sourcebot-dev/sourcebot/pull/325)
13+
- Fixed issue where the symbol hover popover would not appear for large source files. [#325](https://github.com/sourcebot-dev/sourcebot/pull/325)
1214

1315
## [4.0.1] - 2025-05-28
1416

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ export const rangeHighlightingExtension = (range: BrowseHighlightRange) => State
2020
const from = state.doc.line(start.lineNumber).from + start.column - 1;
2121
const to = state.doc.line(end.lineNumber).from + end.column - 1;
2222

23-
return Decoration.set([
24-
markDecoration.range(from, to),
25-
]);
23+
const decorations: Range<Decoration>[] = [];
24+
if (from < to) {
25+
decorations.push(markDecoration.range(from, to));
26+
}
27+
28+
return Decoration.set(decorations);
2629
} else {
2730
const decorations: Range<Decoration>[] = [];
2831
for (let line = start.lineNumber; line <= end.lineNumber; line++) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const symbolHoverTargetsExtension = StateField.define<DecorationSet>({
5252
// @note: we need to use `ensureSyntaxTree` here (as opposed to `syntaxTree`)
5353
// because we want to parse the entire document, not just the text visible in
5454
// the current viewport.
55-
const { data: tree } = measureSync(() => ensureSyntaxTree(state, state.doc.length), "ensureSyntaxTree");
55+
const { data: tree } = measureSync(() => ensureSyntaxTree(state, state.doc.length, Infinity), "ensureSyntaxTree");
5656
const decorations: Range<Decoration>[] = [];
5757

5858
// @note: useful for debugging
@@ -64,7 +64,7 @@ export const symbolHoverTargetsExtension = StateField.define<DecorationSet>({
6464
tree?.iterate({
6565
enter: (node) => {
6666
// console.log(node.type.name, getTextAt(node.from, node.to));
67-
if (NODE_TYPES.includes(node.type.name)) {
67+
if (NODE_TYPES.includes(node.type.name) && node.from < node.to) {
6868
decorations.push(decoration.range(node.from, node.to));
6969
}
7070
},

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ const matchHighlighter = StateField.define<DecorationSet>({
3333
.map((range, index) => {
3434
const { from, to } = convertToCodeMirrorRange(range, transaction.newDoc);
3535
const mark = index === selectedMatchIndex ? selectedMatchMark : matchMark;
36-
return mark.range(from, to);
37-
});
36+
if (from < to) {
37+
return mark.range(from, to);
38+
}
39+
40+
return undefined;
41+
})
42+
.filter((decoration) => decoration !== undefined);
3843

3944
highlights = Decoration.set(decorations)
4045
}

0 commit comments

Comments
 (0)