From c4d418c4d7a4dbec4b8e9443156d759fdcc6282b Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 23 Jan 2019 01:15:39 -0500 Subject: [PATCH] Sorts remotes with default first --- CHANGELOG.md | 4 ++++ src/views/nodes/remotesNode.ts | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9403bd..445b647 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +### Changed + +- Changes the sorting of remotes in the _Repositories_ view to sort the default remote first + ### Fixed - Fixes [#591](https://github.com/eamodio/vscode-gitlens/issues/591) - GitLens Error: Unable to open diff --git a/src/views/nodes/remotesNode.ts b/src/views/nodes/remotesNode.ts index a49985d..bfe3b0e 100644 --- a/src/views/nodes/remotesNode.ts +++ b/src/views/nodes/remotesNode.ts @@ -28,7 +28,11 @@ export class RemotesNode extends ViewNode { return [new MessageNode(this.view, this, 'No remotes could be found')]; } - remotes.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' })); + remotes.sort( + (a, b) => + (a.default ? -1 : 1) - (b.default ? -1 : 1) || + a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }) + ); return [...Iterables.map(remotes, r => new RemoteNode(this.uri, this.view, this, r, this.repo))]; }