Merge branch 'dev' into 'main'

Fix bug find target

See merge request Onyad/clippy-terminal!3
This commit is contained in:
Timofey Khoruzhii 2022-10-30 08:00:24 +00:00
commit d1fbe99800

View file

@ -25,11 +25,13 @@ std::unique_ptr<clippy::targets::RunShellScript> Config::GetTarget(
std::vector<std::string> target_commands;
target_commands.emplace_back("cd " + initial_directory_);
bool target_begin = false;
bool target_exists = false;
bool in_target = false;
while (std::getline(in, current)) {
if (current == target + ":") {
target_begin = true;
target_exists = true;
in_target = true;
continue;
}
@ -37,18 +39,18 @@ std::unique_ptr<clippy::targets::RunShellScript> Config::GetTarget(
continue;
}
if (!std::isspace(current[0]) && target_begin) {
target_begin = false;
if (!std::isspace(current[0])) {
in_target = false;
}
if (target_begin) {
if (in_target) {
target_commands.emplace_back(Strip(std::move(current)));
} else if (current[0] == '!') {
target_commands.emplace_back(current.substr(1, current.size() - 1));
}
}
if (!target_begin) {
if (!target_exists) {
return nullptr;
}