Skip to content

fix: highlight PHP hunks without an opening tag - #496

Merged
barrettruth merged 1 commit into
mainfrom
fix/php-hunk-highlighting
Nov 9, 2026
Merged

barrettruth merged 1 commit into
mainfrom
fix/php-hunk-highlighting

Conversation

@barrettruth

@barrettruth barrettruth commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Problem

PHP hunks rarely contain the file's <?php tag, so the php grammar parses them as HTML. Pure-PHP lines get wrong HTML colors, or Vim syntax Error groups when no parser is installed.

Solution

When a hunk has no PHP tag, or ?> comes before any open tag, add a <?php line before parsing and shift rows by one. This applies to both hunk sides, the @@ function header, and the Vim syntax fallback.

This has some performance implications - only for PHP at least.

Closes #495

@barrettruth
barrettruth force-pushed the fix/php-hunk-highlighting branch from 896c959 to e5b0a61 Compare November 9, 2026 14:34
@barrettruth
barrettruth merged commit e313128 into main Nov 9, 2026
0 of 3 checks passed
@barrettruth
barrettruth deleted the fix/php-hunk-highlighting branch November 9, 2026 14:37
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.

bug: removing context makes it unusable in php

1 participant