File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,26 @@ export class NewBranchDialog extends React.Component<
172
172
* @returns fragment array
173
173
*/
174
174
private _renderItems ( ) {
175
- return this . state . branches . map ( this . _renderItem , this ) ;
175
+ const current = this . props . model . currentBranch . name ;
176
+ return this . state . branches
177
+ . slice ( )
178
+ . sort ( comparator )
179
+ . map ( this . _renderItem , this ) ;
180
+
181
+ /**
182
+ * Comparator function for sorting branches.
183
+ *
184
+ * @private
185
+ * @param a - first branch
186
+ * @param b - second branch
187
+ * @returns integer indicating sort order
188
+ */
189
+ function comparator ( a : Git . IBranch , b : Git . IBranch ) : number {
190
+ if ( a . name === current ) {
191
+ return - 1 ;
192
+ }
193
+ return 0 ;
194
+ }
176
195
}
177
196
178
197
/**
@@ -183,10 +202,6 @@ export class NewBranchDialog extends React.Component<
183
202
* @returns fragment
184
203
*/
185
204
private _renderItem ( branch : Git . IBranch , idx : number ) {
186
- // TODO: consider allowing users to branch from any branch, rather than just the current branch...
187
- if ( branch . name !== this . state . current ) {
188
- return null ;
189
- }
190
205
return (
191
206
< ListItem
192
207
button
You can’t perform that action at this time.
0 commit comments