Skip to content

fix(tui): resolve filetype case-insensitively for suffix and bare names - #39602

Closed
LHMQ878 wants to merge 1 commit into
anomalyco:devfrom
LHMQ878:filetype-lookup
Closed

LHMQ878 wants to merge 1 commit into
anomalyco:devfrom
LHMQ878:filetype-lookup

Conversation

@LHMQ878

@LHMQ878 LHMQ878 commented Jul 30, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #39601

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

filetype() indexed LANGUAGE_EXTENSIONS with path.extname(), an exact case-sensitive lookup. Uppercase extensions (COMPONENT.TSX, main.PY) and extensionless names (Makefile) missed entirely, so those files rendered with no syntax highlighting. It also left five map keys unreachable, since path.extname() only ever returns the final .xxx: makefile, .html.erb, .js.erb, .css.erb, .json.erb.

Now it lowercases the basename and tries each dot-suffix longest-first, falling back to the whole name. That reaches the compound and bare-name keys without adding entries to the map.

diff-viewer.tsx had a byte-identical private copy of the helper with the same bug - it now imports the shared one, dropping 8 lines and an unused path import.

How did you verify your code works?

Extended packages/tui/test/util/filetype.test.ts from 2 to 8 tests: casing, extensionless names, compound suffixes, longest-suffix precedence (data.json -> json but data.json.erb -> erb), paths.

Checked they catch the bugs - against the unfixed source the casing and extensionless tests fail; with the fix 8/8 pass. The two original assertions are unchanged and still pass.

packages/tui: bun typecheck clean, bun test test/util/ 52/52 pass, oxlint warning count identical before and after.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

filetype() indexed LANGUAGE_EXTENSIONS with path.extname(), an exact
case-sensitive lookup. Uppercase extensions (COMPONENT.TSX, main.PY) and
extensionless names (Makefile) missed entirely, so those files rendered
without syntax highlighting. It also left five map keys unreachable:
makefile, .html.erb, .js.erb, .css.erb, .json.erb.

Lowercase the basename and try each dot-suffix longest-first, falling
back to the whole name.

diff-viewer.tsx carried a byte-identical private copy with the same bug;
it now imports the shared helper.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 30, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: TUI syntax highlighting fails on uppercase extensions and extensionless files

1 participant