Skip to content

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

Closed as not planned

Description

@LHMQ878

Description

filetype() in packages/tui/src/util/filetype.ts looks up LANGUAGE_EXTENSIONS[path.extname(input)]. That lookup is exact and case-sensitive, so it misses in three ways:

1. Uppercase extensions get no highlighting. path.extname("COMPONENT.TSX") is ".TSX", which is not a key:

filetype("COMPONENT.TSX") -> undefined   (expected "typescript")
filetype("main.PY")       -> undefined   (expected "python")
filetype("Program.CS")    -> undefined   (expected "csharp")

Common in practice for .PY, .SQL, and Windows-authored files.

2. Extensionless files never match. path.extname("Makefile") is "", so the makefile key in the map is unreachable:

filetype("Makefile") -> undefined   (expected "makefile")

3. Five map keys are dead entries. path.extname() only ever returns the final .xxx, so compound keys can never be hit. These are present in the map but unreachable:

makefile, .html.erb, .js.erb, .css.erb, .json.erb

filetype("index.html.erb") does resolve to "erb", but only via the plain .erb key — the more specific entries are never consulted.

The value feeds tree-sitter highlighting (see packages/tui/src/parsers-config.ts), so a miss means the file renders unhighlighted in the diff viewer and permission prompts.

Separately, packages/tui/src/feature-plugins/system/diff-viewer.tsx:73 contains a byte-identical private copy of filetype(), so the diff viewer carries the same bug independently.

Steps to reproduce

import { filetype } from "./packages/tui/src/util/filetype"

console.log(filetype("COMPONENT.TSX"))  // undefined
console.log(filetype("main.PY"))        // undefined
console.log(filetype("Makefile"))       // undefined

OS

Windows (platform-independent — pure lookup logic)

Activity

  1. github-actions commented on Sep 28, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions