Skip to content

ADFA-2671 Ensure we send a valid color id to Sora tree sitter#942

Merged
hal-eisen-adfa merged 6 commits intostagefrom
ADFA-2671-DiagnosticCoroutineContextException
Feb 12, 2026
Merged

ADFA-2671 Ensure we send a valid color id to Sora tree sitter#942
hal-eisen-adfa merged 6 commits intostagefrom
ADFA-2671-DiagnosticCoroutineContextException

Conversation

@hal-eisen-adfa
Copy link
Collaborator

Under some conditions we were sending bg=0 to the Sora editor which caused color errors to be raised.

@hal-eisen-adfa hal-eisen-adfa requested a review from a team February 7, 2026 18:59
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

📝 Walkthrough
  • Title: Ensure valid color id is sent to Sora tree sitter (prevents color errors caused by bg=0)

  • Changes:

    • Introduced SYNTAX_SPAN_NO_BACKGROUND as a new sentinel color id in SchemeAndroidIDE (post-incremented from endColorId) with javadoc noting it resolves to transparent.
    • SchemeAndroidIDE.applyDefault() sets SYNTAX_SPAN_NO_BACKGROUND to Color.TRANSPARENT.
    • DynamicColorScheme.apply(...) also assigns SYNTAX_SPAN_NO_BACKGROUND = Color.TRANSPARENT (covers dynamic/theme paths).
    • Replaced literal/background-zero usage for keyword styles: SchemeAndroidIDE.forKeyword() now passes SYNTAX_SPAN_NO_BACKGROUND instead of 0.
    • IDEColorScheme.getColor(...) special-cases SYNTAX_SPAN_NO_BACKGROUND to return transparent.
    • StyleDef.makeStyle() computes effectiveBg = (bg > 0 ? bg : SYNTAX_SPAN_NO_BACKGROUND) and passes that to TextStyle.makeStyle — ensuring the sentinel (non-zero) id is used instead of 0.
  • Impact:

    • Prevents sending bg=0 to the Sora editor/tree-sitter integration, eliminating the color errors previously raised and stabilizing syntax highlighting background behavior.
    • Normalizes "no background" handling across static and dynamic schemes by using a dedicated transparent color id.
  • Risks / best-practice notes:

    • ⚠️ Assumption about 0: This fix assumes 0 is not a valid color id. If any other code legitimately uses 0 as a color id, behavior may change; audit callers that treat 0 specially.
    • ⚠️ Public API surface: A new public constant (SYNTAX_SPAN_NO_BACKGROUND) was added to SchemeAndroidIDE. If consumers rely on the symbol table or expect stable exported ids, this increments endColorId and changes id allocation — review external usages and documentation.
    • ⚠️ Theme/render regressions: Using a transparent sentinel could alter rendering in some themes or custom schemes; test across light/dark/custom color schemes (including breakpoint/background usages).
    • ⚠️ Incomplete coverage risk: getColor special-case exists in IDEColorScheme and defaults are set in SchemeAndroidIDE/DynamicColorScheme, but other EditorColorScheme-derived implementations or third-party schemes may not handle the sentinel consistently — ensure all scheme implementations or consumers map the sentinel to a concrete color.
    • Recommendation: Add unit/integration tests validating (a) Sora/tree-sitter never receives a zero bg id, and (b) visual correctness across light/dark/custom schemes; consider a migration note about the new color id and id-space change for downstream integrators.

Walkthrough

Added a new color id SYNTAX_SPAN_NO_BACKGROUND and set it to transparent in default and dynamic schemes; replaced literal/background sentinel usage with this new id and updated IDEColorScheme and StyleDef to treat it as the transparent background sentinel.

Changes

Cohort / File(s) Summary
Scheme Android IDE
common/src/main/java/com/itsaky/androidide/syntax/colorschemes/SchemeAndroidIDE.java
Added public static final int SYNTAX_SPAN_NO_BACKGROUND; applyDefault() sets it to Color.TRANSPARENT; updated forKeyword() to use the new sentinel instead of a literal.
IDE Color Scheme Logic
editor/src/main/java/com/itsaky/androidide/editor/schemes/IDEColorScheme.kt
getColor() returns transparent for SYNTAX_SPAN_NO_BACKGROUND; StyleDef.makeStyle() computes effective background as bg > 0 ? bg : SYNTAX_SPAN_NO_BACKGROUND and passes that to TextStyle.makeStyle().
Dynamic Color Scheme Assignments
common/src/main/java/com/itsaky/androidide/syntax/colorschemes/DynamicColorScheme.kt
Assigned SYNTAX_SPAN_NO_BACKGROUND = Color.TRANSPARENT in dynamic color application paths (near breakpoint line background/indicator) to ensure spans use transparent background.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • jomen-adfa

Poem

🐰 I nudged a color, made it clear and free,
A tiny gap where spans can breathe, you see.
No hidden zero lurking in the code,
A transparent trail along the road,
Hooray — light pixels dance for me! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: ensuring valid color IDs are sent to Sora tree sitter to prevent color errors.
Description check ✅ Passed The description is directly related to the changeset, explaining the issue (sending bg=0 causing errors) and the fix (sending valid color IDs).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ADFA-2671-DiagnosticCoroutineContextException

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jatezzz jatezzz self-requested a review February 9, 2026 15:12
@jatezzz jatezzz requested review from jatezzz and removed request for jatezzz February 9, 2026 15:14
@hal-eisen-adfa hal-eisen-adfa merged commit 69a1d78 into stage Feb 12, 2026
2 checks passed
@hal-eisen-adfa hal-eisen-adfa deleted the ADFA-2671-DiagnosticCoroutineContextException branch February 12, 2026 18:48
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.

3 participants