Log filter: match case-insensitively
The Log window's filter used a case-sensitive substring match, so "error" missed "ERROR" -- inconsistent with the rest of the app. Match case-insensitively. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -117,7 +117,6 @@ UX:
|
|||||||
- **Auto re-attach control** — keep it visible/controllable when not connected (today it can be
|
- **Auto re-attach control** — keep it visible/controllable when not connected (today it can be
|
||||||
enabled-but-invisible).
|
enabled-but-invisible).
|
||||||
- **Tooltips on disabled controls** — explain *why* Inject/subsystem controls are disabled.
|
- **Tooltips on disabled controls** — explain *why* Inject/subsystem controls are disabled.
|
||||||
- **Case-insensitive log filter.**
|
|
||||||
|
|
||||||
Code quality:
|
Code quality:
|
||||||
- **Stale comments** — `hook_guard.hpp` top block (still the old destroy-on-remove model),
|
- **Stale comments** — `hook_guard.hpp` top block (still the old destroy-on-remove model),
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#include "log_panel.hpp"
|
#include "log_panel.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cctype>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
@@ -11,6 +14,24 @@
|
|||||||
namespace coop
|
namespace coop
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
// Case-insensitive substring test, so the log filter matches regardless of case (consistent with the
|
||||||
|
// rest of the app, where "error" should find "ERROR").
|
||||||
|
bool icontains(const std::string& hay, const char* needle)
|
||||||
|
{
|
||||||
|
if (needle == nullptr || needle[0] == '\0')
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto lower = [](std::string s) {
|
||||||
|
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||||
|
return s;
|
||||||
|
};
|
||||||
|
return lower(hay).find(lower(needle)) != std::string::npos;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void LogPanel::add_line(const LogRecord& rec)
|
void LogPanel::add_line(const LogRecord& rec)
|
||||||
{
|
{
|
||||||
if (first_millis_ == 0)
|
if (first_millis_ == 0)
|
||||||
@@ -55,7 +76,7 @@ void LogPanel::draw()
|
|||||||
const bool has_filter = filter_[0] != '\0';
|
const bool has_filter = filter_[0] != '\0';
|
||||||
for (const Line& line : lines_)
|
for (const Line& line : lines_)
|
||||||
{
|
{
|
||||||
if (has_filter && line.text.find(filter_) == std::string::npos)
|
if (has_filter && !icontains(line.text, filter_))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user