Skip to content

Do not fail highlighting when the theme declares no languages - #125

Merged
MegatronKing merged 1 commit into
reqable:mainfrom
koldoon:fix/empty-highlight-theme
Aug 21, 2026
Merged

Do not fail highlighting when the theme declares no languages#125
MegatronKing merged 1 commit into
reqable:mainfrom
koldoon:fix/empty-highlight-theme

Conversation

@koldoon

@koldoon koldoon commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What this fixes

CodeHighlightTheme(languages: {}) is a legitimate thing to build: an editor
showing a file whose language it does not recognise still wants the theme for
its text colours. The payload then carries empty lists of sizes, _run reduces
them, and Bad state: No element is thrown — inside the isolate, so
highlighting dies silently and all that is left is an unhandled exception in the
console.

Unhandled Exception: Bad state: No element
#0      ListBase.reduce (dart:collection/list.dart:187:22)
#1      _CodeHighlightEngine._run (package:re_editor/src/_code_highlight.dart:232:42)

We hit it opening a .log file.

The change

Nothing to highlight is answered with an empty result, exactly as it already is
when there is no theme at all.


Part of a small series from the same project: #122, #123, #124.

`CodeHighlightTheme(languages: {})` is a legitimate thing to build: an editor
that shows a file whose language it does not recognise still wants the theme
for its text colours. The payload then carried empty lists of sizes, `_run`
reduced them, and `Bad state: No element` was thrown — inside the isolate, so
highlighting died silently and all that was left was an unhandled exception in
the console.

Nothing to highlight is now answered with an empty result, as it already is
when there is no theme at all.
@MegatronKing

Copy link
Copy Markdown
Member

LGTM, thanks.

@MegatronKing
MegatronKing merged commit e7bf6e8 into reqable:main Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants