Skip to content

Commit 705e90d

Browse files
Copilotnturinski
andauthored
Fix sortTemplates bug: remove outer scope variable dependency (#4884)
* Initial plan * Fix sortTemplates bug by removing outer scope variable dependency Co-authored-by: nturinski <[email protected]> * Fix duplicate httptrigger regex pattern in getPriority Co-authored-by: nturinski <[email protected]> * Update src/commands/createFunction/FunctionListStep.ts --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: nturinski <[email protected]> Co-authored-by: Nathan <[email protected]>
1 parent 90192d7 commit 705e90d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/commands/createFunction/FunctionListStep.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,15 @@ function sortTemplates(a: FunctionTemplateBase, b: FunctionTemplateBase): number
210210
} else if (/\btimertrigger\b/i.test(id)) {
211211
return 3;
212212
} else {
213-
return a.name.localeCompare(b.name) === -1 ? 4 : 5;
213+
return 4;
214214
}
215215
}
216-
return getPriority(a.id) - getPriority(b.id);
216+
217+
const priorityDiff = getPriority(a.id) - getPriority(b.id);
218+
if (priorityDiff !== 0) {
219+
return priorityDiff;
220+
}
221+
222+
// If priorities are the same, sort alphabetically by name
223+
return a.name.localeCompare(b.name);
217224
}

0 commit comments

Comments
 (0)