fix: strip UTF-8 BOM before parsing settings.json in ponytail-activate (#148) (#151)

settings.json written by Notepad or VS Code on Windows can carry a
UTF-8 BOM. JSON.parse then throws SyntaxError, the outer catch swallows
it, hasStatusline stays false, and the statusline setup nudge is never
emitted.

Strip the leading BOM before parsing, matching the existing handling in
ponytail-mode-tracker.js. (#96 added a null guard but not BOM stripping.)
This commit is contained in:
Lakshya77089
2026-06-18 22:50:10 +02:00
committed by GitHub
parent 55b7cb1925
commit a3bc7db722
+3 -1
View File
@@ -43,7 +43,9 @@ let output = getPonytailInstructions(mode);
if (!isCodex) try {
let hasStatusline = false;
if (fs.existsSync(settingsPath)) {
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
// Strip UTF-8 BOM some editors prepend on Windows (breaks JSON.parse)
const raw = fs.readFileSync(settingsPath, 'utf8').replace(/^\uFEFF/, '');
const settings = JSON.parse(raw);
if (settings.statusLine) {
hasStatusline = true;
}