Skip to content

Commit

Permalink
TERMINAL: Fix autocomplete for mixed case strings (bitburner-official…
Browse files Browse the repository at this point in the history
  • Loading branch information
yichizhng authored May 29, 2024
1 parent bd65856 commit 54d099e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/utils/StringHelperFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,16 @@ function longestCommonStart(strings: string[]): string {
return "";
}

const A: string[] = strings.concat().sort();
const a1: string = A[0];
const a2: string = A[A.length - 1];
const L: number = a1.length;
let i = 0;
const areEqualCaseInsensitive = (a: string, b: string) => a.toUpperCase() === b.toUpperCase();
while (i < L && areEqualCaseInsensitive(a1.charAt(i), a2.charAt(i))) {
i++;
const a1: string = strings[0];
for (let i = 0; i < a1.length; ++i) {
const chr = a1.charAt(i).toUpperCase();
for (let s = 1; s < strings.length; ++s) {
if (chr !== strings[s].charAt(i).toUpperCase()) {
return a1.substring(0, i);
}
}
}

return a1.substring(0, i);
return a1;
}

// Returns whether an array contains entirely of string objects
Expand Down

0 comments on commit 54d099e

Please sign in to comment.