fix: ensure tab completion is not reliant on single-digit volume number

This commit is contained in:
2026-06-16 14:54:49 +02:00
parent 248afb844c
commit f616bf6a86
2 changed files with 23 additions and 5 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 76
#define MONTAUK_BUILD_NUMBER 79
+21 -3
View File
@@ -26,6 +26,20 @@ bool is_executable(const char* path) {
return false;
}
int find_first_slash_pos(const char* string) {
int i = 0;
while (string[i] != '\0') {
if (string[i] == '/') {
return i;
}
i++;
}
return -1;
}
/*
i.e., "shell.elf" => "shell"
*/
@@ -51,19 +65,23 @@ int get_completions( // returns no. of results
for (int i = 0; i < n; i++) {
/*
Shift by 3 characters (names[i] + 3):
Shift by n characters (names[i] + n),
n = position of first slash in path + 1:
"os/shell.elf" => "shell.elf"
This is somewhat of a workaround.
*/
if (montauk::starts_with(names[i] + 3, (const char*)string)) {
int inc = find_first_slash_pos(names[i]) + 1;
if (montauk::starts_with(names[i] + inc, (const char*)string)) {
if (r > arrayMax)
break;
if (!is_executable(names[i]))
continue;
char* p = (char *)names[i] + 3;
char* p = (char *)names[i] + inc;
strip_elf_extension(p);
array[r] = (char *)p;