tom bugfix in complete command

This commit is contained in:
silverqx
2023-07-21 10:42:07 +02:00
parent db97075f9e
commit c25cf277f1
2 changed files with 17 additions and 5 deletions
+5 -1
View File
@@ -38,7 +38,11 @@ namespace Tom::Commands
int run() override;
protected:
#ifndef _MSC_VER
#ifdef _MSC_VER
/*! Currently processed tom command. */
static std::optional<QString>
getCurrentTomCommand(const QStringList &currentCommandSplitted);
#else
/*! Currently processed tom command. */
static std::optional<QString>
getCurrentTomCommand(const QString &commandlineArg, QString::size_type cword);
+12 -4
View File
@@ -99,9 +99,7 @@ int CompleteCommand::run() // NOLINT(readability-function-cognitive-complexity)
const auto currentCommandSplitted = commandlineArg.split(SPACE);
Q_ASSERT(!currentCommandSplitted.isEmpty());
const auto currentCommandArg = currentCommandSplitted.size() >= 2
? std::make_optional(currentCommandSplitted[1])
: std::nullopt;
const auto currentCommandArg = getCurrentTomCommand(currentCommandSplitted);
const auto tomCommandSize = currentCommandSplitted.constFirst().size();
#else
const auto cwordArg = static_cast<QString::size_type>(value(cword_).toLongLong());
@@ -214,7 +212,17 @@ int CompleteCommand::run() // NOLINT(readability-function-cognitive-complexity)
/* protected */
#ifndef _MSC_VER
#ifdef _MSC_VER
std::optional<QString>
CompleteCommand::getCurrentTomCommand(const QStringList &currentCommandSplitted)
{
// It's not a command name
if (currentCommandSplitted.size() < 2 || isLongOption(currentCommandSplitted[1]))
return std::nullopt;
return std::make_optional(currentCommandSplitted[1]);
}
#else
std::optional<QString>
CompleteCommand::getCurrentTomCommand(const QString &commandlineArg,
const QString::size_type cword)