Skip to content

Commit

Permalink
Sort databases by name if their languages are the same
Browse files Browse the repository at this point in the history
  • Loading branch information
shati-patel committed Nov 6, 2023
1 parent 1c19d7a commit c3acca2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CodeQL for Visual Studio Code: Changelog

## [UNRELEASED]
- The "Sort by Language" action in the databases view now sorts by name within each language. [#3055](https://github.com/github/vscode-codeql/pull/3055)

## 1.9.4 - 6 November 2023

Expand Down
12 changes: 10 additions & 2 deletions extensions/ql-vscode/src/databases/local-databases-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,17 @@ class DatabaseTreeDataProvider
case SortOrder.NameDesc:
return db2.name.localeCompare(db1.name, env.language);
case SortOrder.LanguageAsc:
return db1.language.localeCompare(db2.language, env.language);
return (
db1.language.localeCompare(db2.language, env.language) ||
// If the languages are the same, sort by name
db1.name.localeCompare(db2.name, env.language)
);
case SortOrder.LanguageDesc:
return db2.language.localeCompare(db1.language, env.language);
return (
db2.language.localeCompare(db1.language, env.language) ||
// If the languages are the same, sort by name
db2.name.localeCompare(db1.name, env.language)
);
case SortOrder.DateAddedAsc:
return (db1.dateAdded || 0) - (db2.dateAdded || 0);
case SortOrder.DateAddedDesc:
Expand Down

0 comments on commit c3acca2

Please sign in to comment.