Skip to content

Commit

Permalink
add: sort packages
Browse files Browse the repository at this point in the history
  • Loading branch information
r3inbowari committed May 21, 2022
1 parent 3e8522c commit 828b7e2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,9 @@
[0.2.5]

1. add: one icon(.svg) from GoLand
2. add: classify packages for direct or indirect by icon color
2. add: classify packages for (in)direct by icon color
3. chore: fix typos

[0.2.6]

1. add: packages sorting
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ Vscode Market: https://marketplace.visualstudio.com/items?itemName=r3inbowari.go

---

I'm appreciate if you could report an issues or pr. (๑•̀ㅂ•́)و✧
I'm appreciate if you could report an issue or pr. (๑•̀ㅂ•́)و✧
**Enjoy!**
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Go Mod Explorer",
"description": "Displays the External Library for the current go project in the Explorer.",
"publisher": "r3inbowari",
"version": "0.2.5",
"version": "0.2.6",
"repository": {
"type": "git",
"url": "https://github.com/r3inbowari/go-mod-explorer.git"
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function activate(context: vscode.ExtensionContext) {
mt.watch();
mt.update();

// TODO: need fix: delay load after vscode-go
// TODO: need fixed: delay load after vscode-go
try {
execSync('go version');
} catch {
Expand Down
12 changes: 10 additions & 2 deletions src/mod-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class ModTree implements TreeDataProvider<ModItem>, TextDocumentContentPr
if (this._goSDK !== undefined) {
this._rootData?.push(this._goSDK);
}
let packageList: ModItem[] = [];
dat.forEach((res: ModObject, index: number) => {
if (index !== 0 && res.Dir !== undefined) {
let item = new ModItem(res, Uri.parse(res.Dir), res.Dir !== undefined);
Expand All @@ -142,9 +143,16 @@ export class ModTree implements TreeDataProvider<ModItem>, TextDocumentContentPr
res.Indirect ? 'module_indirect.svg' : 'module_direct.svg'
);
item.hideHost(this._hideHost);
this._rootData?.push(item);
packageList.push(item);
}
});

this._rootData = this._rootData.concat(
packageList.sort(({ _modObject: l1 }, { _modObject: l2 }) =>
l1?.Indirect === l2?.Indirect ? 0 : l1?.Indirect ? 1 : -1
)
);

this.updateView();
this._loadingBar.hide();
}
Expand Down Expand Up @@ -240,7 +248,7 @@ export class ModTree implements TreeDataProvider<ModItem>, TextDocumentContentPr
public getChildren(element?: ModItem): ProviderResult<ModItem[]> {
let ret: ModItem[] = [];
if (element === undefined) {
return this._rootData.sort(({ isDirectory: s1 = false }, { isDirectory: s2 = false }) => Number(s2) - Number(s1));
return this._rootData;
} else {
const result = readdirSync(resolvePath(element.resourceUri!));
result.forEach((fileName) => {
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export function queryGoSDK(): ModObject | null {
Path: '',
Version: '',
SDK: true,
Indirect: false,
};
}

Expand Down

0 comments on commit 828b7e2

Please sign in to comment.