Skip to content

chore(deps): upgrade tree-sitter to 0.26, add show-theme wrapping examples#906

Merged
max-sixty merged 11 commits intomainfrom
formatting
Jan 31, 2026
Merged

chore(deps): upgrade tree-sitter to 0.26, add show-theme wrapping examples#906
max-sixty merged 11 commits intomainfrom
formatting

Conversation

@max-sixty
Copy link
Owner

Summary

  • Upgrade tree-sitter ecosystem (0.25 → 0.26) to enable unified multi-line highlighting
  • Add regression tests verifying unified highlighting works for multi-line commands with && and template syntax
  • Update wt config shell show-theme to demonstrate wrapping issue with multi-line strings

Context

With tree-sitter 0.26, unified highlighting correctly identifies operators like && across line breaks. This is groundwork for switching from line-by-line to unified highlighting for better wrapped line handling.

Test plan

  • All existing tests pass
  • New regression tests verify unified highlighting works
  • wt config shell show-theme displays wrapped, multi-line string, and multi-command examples

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

max-sixty and others added 3 commits January 29, 2026 19:12
…mples

Upgrade tree-sitter ecosystem to enable unified multi-line highlighting:
- tree-sitter: 0.25 → 0.26
- tree-sitter-bash: 0.25 → 0.25.1
- tree-sitter-highlight: 0.25 → 0.26

With tree-sitter 0.26, unified highlighting correctly identifies operators
like `&&` across line breaks, enabling future switch from line-by-line to
unified highlighting for better wrapped line handling.

Add regression tests verifying unified highlighting works for:
- Multi-line commands with `&&` at line ends
- Commands containing template syntax (`{{ }}`)

Update `wt config shell show-theme` to demonstrate the wrapping issue:
- Short command
- Long command that wraps
- Multi-line string literal
- Multi-line command

All line types currently display identically, making it hard to distinguish
wrapped continuations from new commands.

Co-Authored-By: Claude <noreply@anthropic.com>
Switch from line-by-line to unified highlighting in format_bash_with_gutter().
This preserves tree-sitter context across newlines, so strings spanning
multiple lines retain their string styling.

Also adds 3 extra spaces of indentation for wrapped continuation lines,
distinguishing terminal-forced wraps from actual newlines in the source.

Co-Authored-By: Claude <noreply@anthropic.com>
# Conflicts:
#	src/commands/configure_shell.rs
Windows templates have CRLF line endings, which caused the style
restoration code to create extra lines. Normalize to LF at input.

Co-Authored-By: Claude <noreply@anthropic.com>
max-sixty and others added 7 commits January 30, 2026 21:25
Tree-sitter's bash grammar fails to parse content when Jinja template
delimiters `{{` and `}}` are split across lines, causing all highlight
events to be suppressed. This manifested as template-heavy hook commands
losing all syntax highlighting.

Fix by replacing template delimiters with bash-valid placeholders
(`_WT_OPEN_`/`_WT_CLOSE_`) before parsing, then restoring them after
highlighting and wrapping. Also skip function styling for placeholders
since tree-sitter misidentifies them as commands.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Move placeholder restoration before wrapping so line width calculations
use the actual 2-char `{{`/`}}` instead of the longer placeholders.
This preserves line wrapping behavior matching main.

Co-Authored-By: Claude <noreply@anthropic.com>
When input ends with a newline, style restoration after the final
newline creates a line containing only ANSI codes. Filter these out
to avoid spurious blank gutter lines in output.

Also use static LazyLock for the ANSI regex pattern.

Co-Authored-By: Claude <noreply@anthropic.com>
- Use plain identifier placeholders (no `$`) to avoid ANSI code insertion
- Trim trailing newlines from input to avoid spurious blank gutter lines
- Remove ANSI regex filtering (no longer needed)

Template delimiters `{{`/`}}` at wrapped line start may be styled as
commands, but this is acceptable given the code simplification.

Co-Authored-By: Claude <noreply@anthropic.com>
…styling

Use `"WTO"`/`"WTC"` as placeholders instead of plain identifiers.
Tree-sitter parses quoted strings as single tokens with consistent
"string" styling (green), so `{{` and `}}` now appear green regardless
of their position in the line.

Co-Authored-By: Claude <noreply@anthropic.com>
Shows how `{{ repo_root }}` and `{{ worktree }}` are styled (green).

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit ee54aa6 into main Jan 31, 2026
21 checks passed
@max-sixty max-sixty deleted the formatting branch January 31, 2026 06:54
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