Skip to content

fix: Fix "Mark decorations may not be empty" issue #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

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

## [4.0.1] - 2025-05-28

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ export const rangeHighlightingExtension = (range: BrowseHighlightRange) => State
const from = state.doc.line(start.lineNumber).from + start.column - 1;
const to = state.doc.line(end.lineNumber).from + end.column - 1;

return Decoration.set([
markDecoration.range(from, to),
]);
const decorations: Range<Decoration>[] = [];
if (from < to) {
decorations.push(markDecoration.range(from, to));
}

return Decoration.set(decorations);
} else {
const decorations: Range<Decoration>[] = [];
for (let line = start.lineNumber; line <= end.lineNumber; line++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const symbolHoverTargetsExtension = StateField.define<DecorationSet>({
// @note: we need to use `ensureSyntaxTree` here (as opposed to `syntaxTree`)
// because we want to parse the entire document, not just the text visible in
// the current viewport.
const { data: tree } = measureSync(() => ensureSyntaxTree(state, state.doc.length), "ensureSyntaxTree");
const { data: tree } = measureSync(() => ensureSyntaxTree(state, state.doc.length, Infinity), "ensureSyntaxTree");
const decorations: Range<Decoration>[] = [];

// @note: useful for debugging
Expand All @@ -64,7 +64,7 @@ export const symbolHoverTargetsExtension = StateField.define<DecorationSet>({
tree?.iterate({
enter: (node) => {
// console.log(node.type.name, getTextAt(node.from, node.to));
if (NODE_TYPES.includes(node.type.name)) {
if (NODE_TYPES.includes(node.type.name) && node.from < node.to) {
decorations.push(decoration.range(node.from, node.to));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ const matchHighlighter = StateField.define<DecorationSet>({
.map((range, index) => {
const { from, to } = convertToCodeMirrorRange(range, transaction.newDoc);
const mark = index === selectedMatchIndex ? selectedMatchMark : matchMark;
return mark.range(from, to);
});
if (from < to) {
return mark.range(from, to);
}

return undefined;
})
.filter((decoration) => decoration !== undefined);

highlights = Decoration.set(decorations)
}
Expand Down