Skip to content

Improve Tree-sitter language support#22

Merged
JackDerksen merged 15 commits intomainfrom
languages
Apr 18, 2026
Merged

Improve Tree-sitter language support#22
JackDerksen merged 15 commits intomainfrom
languages

Conversation

@JackDerksen
Copy link
Copy Markdown
Owner

@JackDerksen JackDerksen commented Apr 15, 2026

  • Added Tree-sitter syntax highlighting for:
    • Markdown
    • Go
    • Python
    • C (and .h)
    • C++ (and .hpp)
    • Python
    • HTML
    • CSS
    • JavaScript
    • TypeScript
    • JSON
    • TOML
    • YAML
  • Added a super basic syntax highlighter fallback for languages that I don't currently have Tree-sitter support for (just highlight comments, numbers, bools, and functions)
  • Added smart auto-indenting for the Tree-sitter languages

Summary by CodeRabbit

  • New Features

    • Syntax highlighting added for many languages (C/C++, CSS, Go, HTML, JS/TS/TSX, JSON, Lua, Markdown, Python, TOML, YAML) and Markdown styling roles.
    • Language-aware smart indentation and smart open-line/enter behavior with lexical fallback support.
  • Bug Fixes

    • Visual-line moves and edits preserve and adjust indentation correctly.
    • Delimiter/analysis caching now uses freshness flags to avoid improper clears.
  • Tests

    • New unit and integration tests covering indentation, smart-enter/open-line, cache staleness, and highlighting.
  • Documentation

    • README/Roadmap updated to reflect completed highlighting and smart-indent items.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Warning

Rate limit exceeded

@JackDerksen has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 26 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 19 minutes and 26 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5015ac88-e99d-444f-98c7-daae5baedb47

📥 Commits

Reviewing files that changed from the base of the PR and between 8ef4080 and a0c4a83.

📒 Files selected for processing (1)
  • crates/redox-tui/src/ui/syntax/mod.rs
📝 Walkthrough

Walkthrough

Integrates Tree-sitter across the TUI: adds multi-language syntax highlighting, smart indentation/open-line logic, lexical fallback spans, and cache staleness tracking; expands language configs/styles (including Markdown) and tests; updates rendering call sites and buffer indentation helpers.

Changes

Cohort / File(s) Summary
Documentation
README.md
Updated UI directory comment and roadmap: expanded syntax-highlighting language checklist and adjusted undo/fuzzy-finder items.
Core Buffer Operations
crates/redox-core/src/buffer/text_buffer/editing.rs
Added pub fn replace_line_indent(&mut self, line: usize, indent: &str) -> Option<(usize, usize)> to replace leading indentation and report removed/added char counts.
Dependencies
crates/redox-tui/Cargo.toml
Appended many tree-sitter-* crates for new language grammars.
Language Registry
crates/redox-tui/src/ui/syntax/languages/mod.rs
Reworked LanguageConfig to support multiple highlight queries, optional inline grammars/queries, scope kinds; added general_capture_mapping, default_refine_role, and multi-language LANGUAGES.
Language Modules
crates/redox-tui/src/ui/syntax/languages/*.rs
Added configs for C, C++, CSS, Go, HTML, JavaScript, JSON, Lua, Markdown, Python, TOML, TypeScript/TSX, YAML; updated Rust config; per-language capture/refine hooks where required.
Syntax Engine & Smart Indent
crates/redox-tui/src/ui/syntax/mod.rs
Extended SyntaxLanguage enum, joined multiple queries, added optional inline-grammar handling, Markdown tokenization, lexical fallback spans, cache staleness APIs, and smart-indent helpers (smart_newline_insert, smart_open_line_insert, desired_indent_for_line).
Cache Staleness
crates/redox-tui/src/ui/overlays.rs, crates/redox-tui/src/app/state.rs
Delimiter pair cache now tracks stale state; get()/has_fresh_analysis()/mark_stale() added and invalidation now marks stale rather than clearing cached data.
Editor Integration
crates/redox-tui/src/app/state/actions.rs, commands.rs, editing.rs
Integrated smart newline/open-line flows using syntax-aware helpers; visual-line moves and other edits call desired_indent_for_line and use replace_line_indent to adjust lines and cursor columns.
Rendering Pipeline
crates/redox-tui/src/lib.rs
Conditional scope-guide computation (scope_guides_enabled), added lexical_fallback_enabled flag to draw_snapshot_lines, and use lexical fallback when Tree-sitter spans are missing.
Styling
crates/redox-tui/src/ui/style.rs
Added Markdown SyntaxRole variants and corresponding SyntaxStyle fields; updated color_for and tests.
Tests
crates/redox-tui/src/app/state/tests.rs, ui/... tests
Expanded and adjusted tests: cache staleness/visibility assertions and 15+ smart-indent/integration tests across languages and visual reindentation.

Sequence Diagram

sequenceDiagram
    participant Editor as Editor (InputAction)
    participant Buffer as TextBuffer
    participant Syntax as SyntaxHighlighter
    participant Language as LanguageConfig
    participant Display as Display

    Editor->>Buffer: get cursor position
    Buffer-->>Editor: cursor_pos
    Editor->>Syntax: language_for_path(buffer.path)
    Syntax-->>Editor: language_option
    Editor->>Syntax: smart_newline_insert(buffer, language, cursor)
    Note over Syntax,Language: parse with Tree-sitter / combine queries → compute desired indent
    Syntax->>Language: use grammar & highlight queries
    Language-->>Syntax: scope/indent info
    Syntax-->>Editor: (insert_text, new_cursor)? 
    alt smart indent returned
        Editor->>Buffer: insert(insert_text) and set cursor
        Buffer-->>Display: updated content
    else fallback
        Editor->>Buffer: insert_newline() and set fallback cursor
        Buffer-->>Display: updated content
    end
    Editor->>Syntax: mark_cache_stale() (invalidate freshness, keep cached analysis)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • PR #21: Directly related — extends and modifies the same syntax-highlighter, cache, and analysis-versioned infrastructure this change builds on.
  • PR #20: Directly related — previous changes to delimiter-pair caching and invalidation overlap with the new staleness approach.
  • PR #11: Related — prior syntax/highlighter foundation and language-detection work that this PR expands with broad Tree-sitter support and smart-indent integration.

Poem

🐰 I hopped through grammars, stitched scopes in night and day,
I taught the lines to mind their tabs and where to stay,
I marked caches stale — not lost — so maps remain in place,
With smart-indent and many tongues, the editor finds its grace,
A rabbit cheers: new languages, new light, a gentler space!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.21% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Improve Tree-sitter language support' accurately captures the main objective of the PR, which adds multi-language Tree-sitter support and related features across the codebase.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch languages

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/redox-tui/src/app/state/editing.rs (1)

614-619: ⚠️ Potential issue | 🟠 Major

Reindent happens before line relocation, causing stale column adjustment targets.

At Line 614 and Line 654, reindent_active_line_span runs before updating visual_anchor.line / cursor.line. Since column correction is line-matched, indent deltas can be skipped for moved selections.

✅ Suggested fix (reorder operations)
@@
-            self.reindent_active_line_span(new_start, new_end);
             let view = self.views.entry(active_id).or_default();
             if let Some(anchor) = view.visual_anchor.as_mut() {
                 anchor.line = anchor.line.saturating_sub(delta);
             }
             view.cursor.cursor.line = view.cursor.cursor.line.saturating_sub(delta);
+            self.reindent_active_line_span(new_start, new_end);
             let buffer = self.session.active_buffer();
             view.cursor
                 .reconcile_after_edit(buffer, viewport_width_cells, text_vh);
@@
-            self.reindent_active_line_span(new_start, new_end);
             let view = self.views.entry(active_id).or_default();
             if let Some(anchor) = view.visual_anchor.as_mut() {
                 anchor.line = anchor.line.saturating_add(delta);
             }
             view.cursor.cursor.line = view.cursor.cursor.line.saturating_add(delta);
+            self.reindent_active_line_span(new_start, new_end);
             let buffer = self.session.active_buffer();
             view.cursor
                 .reconcile_after_edit(buffer, viewport_width_cells, text_vh);

Also applies to: 654-659

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/redox-tui/src/app/state/editing.rs` around lines 614 - 619, The
reindent is being called before the selection's lines are relocated, so
column-based corrections use stale line positions; move the call to
reindent_active_line_span to after you update the view's positions.
Specifically, for the blocks that fetch view via
self.views.entry(active_id).or_default() and then adjust anchor.line
(visual_anchor.as_mut() -> anchor.line = anchor.line.saturating_sub(delta)) and
view.cursor.cursor.line = view.cursor.cursor.line.saturating_sub(delta), reorder
so the visual_anchor and view.cursor.cursor.line updates happen first and then
call reindent_active_line_span(new_start, new_end); apply the same reorder for
the other occurrence that adjusts lines (the block around the second instance
currently calling reindent before updating anchor/cursor).
🧹 Nitpick comments (1)
crates/redox-tui/src/ui/syntax/languages/json.rs (1)

7-17: Consider adding scope_kinds for JSON smart indentation.

The scope_kinds array is empty, which means smart auto-indentation won't recognize JSON objects/arrays as scopes. If smart indentation within JSON structures is desired, consider:

-    scope_kinds: &[],
+    scope_kinds: &["object", "array"],

This is optional since JSON editing patterns may differ from code, but it would provide consistency with the PR's smart-indent goals.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/redox-tui/src/ui/syntax/languages/json.rs` around lines 7 - 17, The
JSON_LANGUAGE config currently has an empty scope_kinds which prevents the smart
indenter from treating JSON objects/arrays as block scopes; update the
JSON_LANGUAGE.scope_kinds to include the JSON tree-sitter node kinds that should
act as scopes (e.g. "object" and "array", and optionally "pair" if you want
key/value pair-aware indentation) so the smart-indent logic can detect and
indent inside JSON structures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/redox-tui/src/ui/overlays.rs`:
- Around line 66-84: The cache currently exposes stale analyses via get(), so
update the cache API and call sites to prevent rendering stale data: make get()
return only fresh analyses (use has_fresh_analysis()) or add a new get_fresh()
that returns Option<DelimiterAnalysis> only when has_fresh_analysis() is true;
modify callers (e.g., the render path that calls
view.delimiter_pair_cache.get()) to use the freshness-aware accessor; ensure
install(), mark_stale(), has_fresh_analysis(), and the test-only
has_stale_analysis() remain consistent with the new getter behavior so stale
analyses are never returned by the public get() used for rendering.

In `@crates/redox-tui/src/ui/syntax/languages/python.rs`:
- Around line 15-24: The scope_kinds array in python.rs currently lists only
parent statement nodes so clause blocks like else/except/finally resolve to the
parent; update the scope_kinds definition (the scope_kinds slice) to include the
Tree-sitter Python clause node kinds: "else_clause", "except_clause",
"except_group_clause", and "finally_clause" so each clause is treated as its own
scope for guides/indentation.

In `@crates/redox-tui/src/ui/syntax/mod.rs`:
- Around line 521-529: The virtual source rewrite currently replaces the text
after the cursor with `left`, producing `prefix + prefix`; instead, when the
cursor is mid-line you must remove the right-hand remainder so the parser sees
the line truncated at the cursor. In the block that builds `virtual_source`
(using `source`, `source_line_start_byte`, `left`, `line_text`, `cursor_byte`,
`line_end`), change the `source.replace_range(cursor_byte..line_end, &left)` to
remove the right side (e.g. `source.replace_range(cursor_byte..line_end, "")`)
so the virtual buffer contains the line split at the cursor rather than
duplicated prefix.
- Around line 1130-1145: The fallback comment detection in lexical_comment_end
treats any ';' or '#' anywhere as comment start, causing false positives (e.g.,
"foo(); bar();"). Modify the branch that matches b'#' | b';' so it only returns
Some(bytes.len()) when the character is at the start of the line or preceded by
whitespace/newline; otherwise return None. In other words, in
lexical_comment_end check the byte before cursor (or cursor==0) and only treat
'#' or ';' as a comment starter if cursor==0 ||
previous_byte.is_ascii_whitespace() || previous_byte == b'\n', keeping other
branches (//, --, /* */) unchanged and referencing the lexical_comment_end
function and the match arm that currently uses matches!(bytes[cursor], b'#' |
b';').
- Around line 669-686: opens_line() currently treats any trailing '>' as an
opening tag which makes closing tags (</div>) and self-closing tags (<img />)
indent the next line; change the HTML/TSX branch so it only returns true for
actual opening tags by ensuring the line text is not a closing tag (doesn't
start with "</" after trimming) and not a self-closing tag (doesn't end with
"/>" allowing for trailing whitespace) before calling opens_html_tag, or
alternatively update opens_html_tag to explicitly return false for
closing/self-closing tags; target the opens_line function and opens_html_tag
helper and keep existing checks using trailing_significant_char,
paired_closer_for, and node_kind_at_byte intact.
- Around line 393-404: The stale-scope fallback is currently reused for any
cursor in the same language; change the stale selection logic so it only returns
the cached scope when the cached entry matches the current cursor position. In
the block that computes stale_scope (using cache_stale, language, and
self.active_scope_cache), add a predicate that compares the cached entry's
cursor/location to the current cursor (and buffer if needed) before returning
cached.scope, so active_scope_pair_cached(buffer, language, analysis_version,
cursor).or(stale_scope) only uses stale_scope when the cached cursor equals the
current cursor.

In `@README.md`:
- Around line 200-202: The three checklist items "json", "toml", and "yaml" in
README.md are indented inconsistently causing markdownlint MD005; fix by
aligning their indentation to match the surrounding nested roadmap list (use the
same number of leading spaces or tabs as other nested items) so they appear as
properly nested bullets under their parent list entry; locate the lines
containing "json", "toml", and "yaml" and adjust their leading whitespace to the
same level as other nested items.

---

Outside diff comments:
In `@crates/redox-tui/src/app/state/editing.rs`:
- Around line 614-619: The reindent is being called before the selection's lines
are relocated, so column-based corrections use stale line positions; move the
call to reindent_active_line_span to after you update the view's positions.
Specifically, for the blocks that fetch view via
self.views.entry(active_id).or_default() and then adjust anchor.line
(visual_anchor.as_mut() -> anchor.line = anchor.line.saturating_sub(delta)) and
view.cursor.cursor.line = view.cursor.cursor.line.saturating_sub(delta), reorder
so the visual_anchor and view.cursor.cursor.line updates happen first and then
call reindent_active_line_span(new_start, new_end); apply the same reorder for
the other occurrence that adjusts lines (the block around the second instance
currently calling reindent before updating anchor/cursor).

---

Nitpick comments:
In `@crates/redox-tui/src/ui/syntax/languages/json.rs`:
- Around line 7-17: The JSON_LANGUAGE config currently has an empty scope_kinds
which prevents the smart indenter from treating JSON objects/arrays as block
scopes; update the JSON_LANGUAGE.scope_kinds to include the JSON tree-sitter
node kinds that should act as scopes (e.g. "object" and "array", and optionally
"pair" if you want key/value pair-aware indentation) so the smart-indent logic
can detect and indent inside JSON structures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7143b714-5101-4ea3-ad5b-ced2e8b5651a

📥 Commits

Reviewing files that changed from the base of the PR and between 750eae8 and 6d7bd3c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (27)
  • README.md
  • crates/redox-core/src/buffer/text_buffer/editing.rs
  • crates/redox-tui/Cargo.toml
  • crates/redox-tui/src/app/state.rs
  • crates/redox-tui/src/app/state/actions.rs
  • crates/redox-tui/src/app/state/commands.rs
  • crates/redox-tui/src/app/state/editing.rs
  • crates/redox-tui/src/app/state/tests.rs
  • crates/redox-tui/src/lib.rs
  • crates/redox-tui/src/ui/overlays.rs
  • crates/redox-tui/src/ui/style.rs
  • crates/redox-tui/src/ui/syntax/languages/c.rs
  • crates/redox-tui/src/ui/syntax/languages/cpp.rs
  • crates/redox-tui/src/ui/syntax/languages/css.rs
  • crates/redox-tui/src/ui/syntax/languages/go.rs
  • crates/redox-tui/src/ui/syntax/languages/html.rs
  • crates/redox-tui/src/ui/syntax/languages/javascript.rs
  • crates/redox-tui/src/ui/syntax/languages/json.rs
  • crates/redox-tui/src/ui/syntax/languages/lua.rs
  • crates/redox-tui/src/ui/syntax/languages/markdown.rs
  • crates/redox-tui/src/ui/syntax/languages/mod.rs
  • crates/redox-tui/src/ui/syntax/languages/python.rs
  • crates/redox-tui/src/ui/syntax/languages/rust.rs
  • crates/redox-tui/src/ui/syntax/languages/toml.rs
  • crates/redox-tui/src/ui/syntax/languages/typescript.rs
  • crates/redox-tui/src/ui/syntax/languages/yaml.rs
  • crates/redox-tui/src/ui/syntax/mod.rs

Comment thread crates/redox-tui/src/ui/overlays.rs
Comment thread crates/redox-tui/src/ui/syntax/languages/python.rs
Comment thread crates/redox-tui/src/ui/syntax/mod.rs
Comment thread crates/redox-tui/src/ui/syntax/mod.rs
Comment thread crates/redox-tui/src/ui/syntax/mod.rs
Comment thread crates/redox-tui/src/ui/syntax/mod.rs
Comment thread README.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/redox-tui/src/app/state/tests.rs (1)

3702-3942: Smart-indent tests look coherent with the Tree-sitter indent logic.

The new suite covers the main branches of desired_indent_for_line_source / indent_after_line:

  • Opening-delimiter Enter (Rust {, angle in HTML, quotes, backticks in Markdown) → adds one tab level.
  • Splitting a paired closer on the same line → inserts indented blank line and pushes the closer down.
  • o/O between matching delimiters re-uses the smart indent.
  • Markdown list continuation / blank-line non-skip / partial-tab flooring behaviors match floored_indent + markdown_indent_after_line semantics.
  • cc indent preservation and visual move reindent against the new Tree-sitter scope.

One minor thing worth double-checking: insert_enter_splits_backtick_delimiters_with_smart_indent (Lines 3789-3806) relies on a bare ` being treated as a paired delimiter by paired_closer_for. Backticks are less conventional as a "pair" than {}/()/<>/"", so if paired_closer_for is ever tightened to only handle brackets/quotes, this test will regress silently from a "smart indent" test into an "unrelated newline" test. Worth a brief comment in the test noting the assumption, or pinning it via a direct unit test on paired_closer_for('')`.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/redox-tui/src/app/state/tests.rs` around lines 3702 - 3942, The
backtick test relies on paired_closer_for treating '`' as a paired delimiter,
which could silently regress; update the test
insert_enter_splits_backtick_delimiters_with_smart_indent to include a short
comment stating this assumption and add (or pin) a small direct unit test that
asserts paired_closer_for('`') returns the expected closer so the contract is
explicit and will fail-fast if paired_closer_for is tightened.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/redox-tui/src/app/state/tests.rs`:
- Around line 3702-3942: The backtick test relies on paired_closer_for treating
'`' as a paired delimiter, which could silently regress; update the test
insert_enter_splits_backtick_delimiters_with_smart_indent to include a short
comment stating this assumption and add (or pin) a small direct unit test that
asserts paired_closer_for('`') returns the expected closer so the contract is
explicit and will fail-fast if paired_closer_for is tightened.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 17c2c992-058c-42ac-94f9-7226ccec5de2

📥 Commits

Reviewing files that changed from the base of the PR and between 6d7bd3c and 6720cf6.

📒 Files selected for processing (6)
  • README.md
  • crates/redox-tui/src/app/state/editing.rs
  • crates/redox-tui/src/app/state/tests.rs
  • crates/redox-tui/src/ui/overlays.rs
  • crates/redox-tui/src/ui/syntax/languages/python.rs
  • crates/redox-tui/src/ui/syntax/mod.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/redox-tui/src/ui/syntax/mod.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • README.md
  • crates/redox-tui/src/app/state/editing.rs
  • crates/redox-tui/src/ui/overlays.rs
  • crates/redox-tui/src/ui/syntax/languages/python.rs

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/redox-tui/src/ui/syntax/mod.rs (1)

348-360: ⚠️ Potential issue | 🟡 Minor

Check cache_stale before returning the active-scope cache.

Line 350 can return a cached scope even after mark_cache_stale() if the caller passes the same analysis_version and cursor. That bypasses the stale guard on Line 358 and makes the non-display API expose stale data.

Proposed fix
         let language = language?;
         let cursor_char = buffer.pos_to_char(cursor);
+        if self.cache_stale {
+            return None;
+        }
+
         if let Some(cached) = self.active_scope_cache
             && cached.language == language
             && cached.analysis_version == analysis_version
             && cached.cursor_char == cursor_char
         {
             return cached.scope;
         }
 
-        if self.cache_stale {
-            return None;
-        }
-
         let config = language_config_for(language)?;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/redox-tui/src/ui/syntax/mod.rs` around lines 348 - 360, The code
currently returns self.active_scope_cache even when self.cache_stale is true if
the cached entry matches language/analysis_version/cursor; change the logic so
self.cache_stale is checked before returning cached data—either move the "if
self.cache_stale { return None; }" above the active-scope cache branch or
include "&& !self.cache_stale" in the cached-match condition; ensure you
reference self.active_scope_cache, cached.analysis_version, cached.cursor_char,
and self.cache_stale when making the check so stale caches are never returned
(also keep the language = language? and cursor_char lookup intact).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/redox-tui/src/ui/syntax/mod.rs`:
- Around line 671-677: The opens_line function currently treats any character
with a paired closer (via paired_closer_for) as opening a block, which wrongly
treats inline backticks as block openers; update opens_line (and the same logic
around the other occurrence at the paired-closing check between lines 801–807)
to explicitly ignore the backtick character: after obtaining ch from
trailing_significant_char, return false if ch == '`' before calling
paired_closer_for, so inline Markdown code (e.g., `code`) will not trigger block
indentation.

---

Outside diff comments:
In `@crates/redox-tui/src/ui/syntax/mod.rs`:
- Around line 348-360: The code currently returns self.active_scope_cache even
when self.cache_stale is true if the cached entry matches
language/analysis_version/cursor; change the logic so self.cache_stale is
checked before returning cached data—either move the "if self.cache_stale {
return None; }" above the active-scope cache branch or include "&&
!self.cache_stale" in the cached-match condition; ensure you reference
self.active_scope_cache, cached.analysis_version, cached.cursor_char, and
self.cache_stale when making the check so stale caches are never returned (also
keep the language = language? and cursor_char lookup intact).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6fc9e847-34c0-4e2b-8259-e9283a7ffd85

📥 Commits

Reviewing files that changed from the base of the PR and between 6720cf6 and 8ef4080.

📒 Files selected for processing (2)
  • crates/redox-tui/src/app/state/tests.rs
  • crates/redox-tui/src/ui/syntax/mod.rs

Comment thread crates/redox-tui/src/ui/syntax/mod.rs
@JackDerksen JackDerksen merged commit 6d22ccf into main Apr 18, 2026
2 checks passed
@JackDerksen JackDerksen deleted the languages branch April 18, 2026 03:24
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.

1 participant