Skip to content

Commit 82c54fa

Browse files
committed
Address third round of Copilot review comments on PR #121
1 parent 8123ebf commit 82c54fa

2 files changed

Lines changed: 46 additions & 6 deletions

File tree

github-code-search.ts

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,27 @@ async function searchAction(
332332
// ─── Team-prefix grouping ─────────────────────────────────────────────────
333333
const pickTeams: Record<string, string> = {};
334334
if (!opts.groupByTeamPrefix && opts.pickTeam && opts.pickTeam.length > 0) {
335-
process.stderr.write(
336-
pc.yellow(
337-
"warning: --pick-team has no effect without --group-by-team-prefix; picks are being ignored.\n",
338-
),
339-
);
335+
// Emit per-assignment warnings (same validation as when grouping is enabled) — see issue #121.
336+
for (const assignment of opts.pickTeam) {
337+
const eqIndex = assignment.indexOf("=");
338+
if (eqIndex === -1) {
339+
process.stderr.write(
340+
`warning: --pick-team "${assignment}" is missing the = separator; skipping\n`,
341+
);
342+
continue;
343+
}
344+
const combined = assignment.slice(0, eqIndex).trim();
345+
const chosen = assignment.slice(eqIndex + 1).trim();
346+
if (!combined || !chosen) {
347+
process.stderr.write(
348+
`warning: --pick-team "${assignment}" must have non-empty combined and chosen labels; skipping\n`,
349+
);
350+
continue;
351+
}
352+
process.stderr.write(
353+
`warning: --pick-team: no section found with label "${combined}"\n (no combined sections remain)\n`,
354+
);
355+
}
340356
}
341357
if (opts.groupByTeamPrefix) {
342358
const prefixes = opts.groupByTeamPrefix
@@ -368,6 +384,18 @@ async function searchAction(
368384
);
369385
continue;
370386
}
387+
// Validate that chosen is one of the teams in the combined label — see issue #121.
388+
const combinedCandidates = combined
389+
.split(" + ")
390+
.map((part) => part.trim())
391+
.filter((part) => part.length > 0);
392+
if (combinedCandidates.length > 1 && !combinedCandidates.includes(chosen)) {
393+
process.stderr.write(
394+
`warning: --pick-team "${assignment}" has chosen label "${chosen}" which is not one of the teams in ` +
395+
`"${combined}". Allowed choices: ${combinedCandidates.map((c) => `"${c}"`).join(", ")}; skipping\n`,
396+
);
397+
continue;
398+
}
371399
const updated = applyTeamPick(sections, combined, chosen);
372400
if (updated === sections) {
373401
// applyTeamPick returns the same reference when the combined label is not found.

src/render.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,19 @@ export function renderGroups(
557557
: row.sectionLabel.length > maxCharsWithHint
558558
? row.sectionLabel.slice(0, Math.max(1, maxCharsWithHint - 1)) + "…"
559559
: row.sectionLabel;
560-
lines.push(`${pc.bgMagenta(pc.bold(`── ${activeLabel} `))}${pc.dim(hintPlain)}`);
560+
// Fix: clip the hint itself when it doesn't fit in the remaining space — see issue #121.
561+
const remainingWidth = termWidth - SECTION_FIXED - activeLabel.length;
562+
let hint = "";
563+
if (remainingWidth > 0) {
564+
if (hintPlain.length <= remainingWidth) {
565+
hint = hintPlain;
566+
} else if (remainingWidth === 1) {
567+
hint = "…";
568+
} else {
569+
hint = hintPlain.slice(0, remainingWidth - 1) + "…";
570+
}
571+
}
572+
lines.push(`${pc.bgMagenta(pc.bold(`── ${activeLabel} `))}${hint ? pc.dim(hint) : ""}`);
561573
} else {
562574
lines.push(pc.bgMagenta(pc.bold(`── ${label} `)));
563575
}

0 commit comments

Comments
 (0)