chore(deps): upgrade tree-sitter to 0.26, add show-theme wrapping examples#906
Merged
chore(deps): upgrade tree-sitter to 0.26, add show-theme wrapping examples#906
Conversation
…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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
&&and template syntaxwt config shell show-themeto demonstrate wrapping issue with multi-line stringsContext
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
wt config shell show-themedisplays wrapped, multi-line string, and multi-command examples🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com