Repository navigation
fix(editor): drop the unreachable uppercase .R extension key - #11322
Conversation
Greptile SummaryThis PR removes the unreachable
Confidence Score: 5/5Safe to merge — removes one dead map entry that was provably unreachable and adds a test to guard the normalization behaviour. The deletion is of a single lookup-table entry that detectLanguage could never reach due to the toLowerCase() call that precedes every map access. The added test directly exercises both lowercase and uppercase R file paths, so any future regression in the normalization step would be caught immediately. The change has no runtime-visible effect and no coupling to any other code path. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/lib/language-detect.ts | Removes the unreachable '.R': 'r' map entry; detectLanguage lowercases the extension before lookup so this key could never be matched. |
| src/renderer/src/lib/language-detect.test.ts | Adds a test asserting both model.r and MODEL.R resolve to 'r', providing a regression guard for the lowercasing behaviour in detectLanguage. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["detectLanguage(filePath)"] --> B["Split path, extract filename"]
B --> C{"FILENAME_TO_LANGUAGE\nhas exact filename?"}
C -- Yes --> D["Return language"]
C -- No --> E["extname(filename).toLowerCase()"]
E --> F{"EXT_TO_LANGUAGE\nhas lowercased ext?"}
F -- Yes --> G["Return language"]
F -- No --> H["Return 'plaintext'"]
subgraph "EXT_TO_LANGUAGE (after PR)"
I["'.r' → 'r'"]
J["❌ '.R' removed (was unreachable)"]
end
E -->|"'.R' → '.r' after toLowerCase"| F
style J fill:#f88,stroke:#c00,color:#000
style I fill:#8f8,stroke:#090,color:#000
Reviews (3): Last reviewed commit: "fix(editor): drop the unreachable upperc..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between e549dd3 and 6192b53fa91af6ccd43446047bf96561bf31b97a. 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughUpdated language detection to rely on lowercasing before mapping the 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
6192b53 to
4c8b7a0
Compare
detectLanguage lowercases the extension before the table lookup, so the '.R' entry can never be reached — '.r' already covers every casing. It is also the only key in the table with an uppercase character, and leaving it suggests uppercase extensions need their own rows.
4c8b7a0 to
9bcf121
Compare
…i#11322) detectLanguage lowercases the extension before the table lookup, so the '.R' entry can never be reached — '.r' already covers every casing. It is also the only key in the table with an uppercase character, and leaving it suggests uppercase extensions need their own rows.
Summary
EXT_TO_LANGUAGEhas both'.r'and'.R'mapped tor, but the lookup key is lowercased first:No input can ever reach the
'.R'entry —'.r'already coversmodel.R,MODEL.Rand every other casing. Removing it changes no behaviour.It is worth removing rather than leaving alone: as written, the entry reads like uppercase extensions need their own row, which invites the same addition for
.SVG,.JSONand so on.'.R'is currently the only key in the table with an uppercase character, so this keeps that property true.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildThe two unchecked boxes are explained under Notes.
AI Review Report
Reviewed with an AI coding agent. The check that mattered was whether the entry is genuinely unreachable rather than merely redundant:
detectLanguagelowercases the extension before the lookup (language-detect.ts:123), andFILENAME_TO_LANGUAGE— which is consulted first and is not lowercased — contains no key ending in.R, so there is no path that bypasses the normalization. A scan of the table confirmed'.R'is the only key containing an uppercase character, so no sibling entry has the same problem.The added test asserts both
model.randMODEL.Rresolve tor, so if the lowercasing indetectLanguagewere ever removed, this deletion would surface as a failing test rather than as silently broken highlighting for uppercase.Rfiles.Cross-platform compatibility (macOS, Linux, Windows) was explicitly checked. This is the removal of one entry from a lookup table; no platform branch, path handling, shortcut, label, shell behavior or Electron-specific code is involved. Case-insensitive filesystems are the reason the lowercasing exists in the first place, and that behaviour is unchanged and now covered by a test.
Security Audit
No risk surface. One line is removed from a static lookup table and a test is added. No input handling, command execution, path resolution, auth, secrets, IPC or dependency changes.
Notes
pnpm lint: oxlint and the code-quality audits pass. The chain stops later atverify:skill-bundle-manifest, which reports stale generated artifacts underresources/skills/— a pre-existing state unrelated to this change, and those files are not part of this diff.pnpm test: the full suite on a Windows machine fails a set of pre-existing tests that require a POSIX shell (spawn /bin/sh ENOENT); the count is unchanged by this PR.language-detect.test.tspasses 11/11.