Skip to content

Commit

Permalink
trying to fix load issues #274
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoescolar committed Dec 8, 2023
1 parent 8afac61 commit 0cabe81
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/extensions/glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export function globTest(pattern: string | string[], input: string): boolean {

export async function globFileSearch(workingFolder: string, pattern: string, exclude?:string | string[]): Promise<string[]> {
const result: string[] = [];
if (! await fs.exists(workingFolder)) {
return result;
}

if (! await fs.isDirectory(workingFolder)) {
return result;
}

if (!isGlobPattern(pattern)) {
return [ path.join(workingFolder, pattern) ];
}
Expand Down
11 changes: 11 additions & 0 deletions src/extensions/hash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

// Fast, simple and insecure hash function
export function fasthash(str: string): string {
let hash = 0;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hash = (hash << 5) - hash + char;
hash &= hash; // Convert to 32bit integer
}
return new Uint32Array([hash])[0].toString(36);
}
15 changes: 9 additions & 6 deletions src/tree/TreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from "vscode";
import * as path from "@extensions/path";
import * as config from "@extensions/config";
import { fasthash } from "@extensions/hash";
import { ProjectInSolution, SolutionFile } from "@core/Solutions";
import { Project } from "@core/Projects";
import * as TreeItemIconProvider from "./TreeItemIconProvider";
Expand Down Expand Up @@ -120,13 +121,14 @@ export abstract class TreeItem extends vscode.TreeItem {
}

protected createId(): void {
let id: string;
let id: string = `${this.label}-${this.path ?? ''}-${this.contextValue}`;
if (!this.parent && this.solution) {
id = this.solution.fullPath + '-' + id;
}

id = fasthash(id);
if (this.parent) {
id = this.parent.id + '-' + this.label + '[' + this.contextValue + ']';
} else if (this.solution) {
id = this.solution.fullPath + '[' + this.contextValue + ']';
} else {
id = this.label + '[' + this.contextValue + ']';
id = this.parent.id + '-' + id;
}

this.id = id;
Expand All @@ -145,6 +147,7 @@ export abstract class TreeItem extends vscode.TreeItem {
} else {
let fullpath = this.path;
if (!fullpath) { fullpath = path.dirname(this.solution.fullPath); }
//this.resourceUri = vscode.Uri.file(fullpath);
this.loadThemeIcon(fullpath);
}
}
Expand Down

0 comments on commit 0cabe81

Please sign in to comment.