From 580a95348a98214377a99874f29d4a0cb0629b57 Mon Sep 17 00:00:00 2001 From: Daniel Hammer Date: Thu, 18 Jun 2026 07:56:00 +0200 Subject: [PATCH] feat: complete command completion in shell --- kernel/src/Api/BuildNo.hpp | 2 +- programs/src/shell/main.cpp | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/kernel/src/Api/BuildNo.hpp b/kernel/src/Api/BuildNo.hpp index 4e12ae4..5447694 100644 --- a/kernel/src/Api/BuildNo.hpp +++ b/kernel/src/Api/BuildNo.hpp @@ -12,4 +12,4 @@ #pragma once -#define MONTAUK_BUILD_NUMBER 108 +#define MONTAUK_BUILD_NUMBER 110 diff --git a/programs/src/shell/main.cpp b/programs/src/shell/main.cpp index fc77818..b1ab645 100644 --- a/programs/src/shell/main.cpp +++ b/programs/src/shell/main.cpp @@ -441,15 +441,25 @@ extern "C" void _start() { char* table[128] = { }; int n = get_completions(line, table, 128, cwd, current_drive); - montauk::print("\n"); - for (int i = 0; i < n; i++) { - montauk::print(" "); - montauk::print(table[i]); - montauk::print("\n"); - } + // Command completion if there is only 1 match + if (n == 1) { + size_t chars_already_typed = pos; + pos = 0; - pos = 0; - prompt(); + montauk::strncpy(line, table[0], 256); + pos = montauk::slen(table[0]); + montauk::print(table[0] + chars_already_typed); + } else { // If more than one result, print multiple results + montauk::print("\n"); + for (int i = 0; i < n; i++) { + montauk::print(" "); + montauk::print(table[i]); + montauk::print("\n"); + } + + pos = 0; + prompt(); + } continue; }