mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +01:00
TERMINAL: Fix autocomplete for mixed case strings (#1323)
This commit is contained in:
parent
bd6585617c
commit
54d099e552
@ -59,18 +59,17 @@ 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;
|
||||
}
|
||||
|
||||
// Returns whether an array contains entirely of string objects
|
||||
function containsAllStrings(arr: string[]): boolean {
|
||||
|
Loading…
Reference in New Issue
Block a user