Prefer the tracked layout when recent input matches several layouts
This commit is contained in:
1 parent
2869d584d8
commit
160cece79d
2 files changed
+28
-6
No files matched your search
+16
-6
@@ -645,15 +645,25 @@ int Run::match(const std::wstring &text, const std::vector<Layout> &layouts, con
|
||||
{
|
||||
if (text.size() != keys.size() || overflow)
|
||||
return -1;
|
||||
const auto normalized = lower(text);
|
||||
int fallback = -1;
|
||||
for (int i = 0; i < (int)layouts.size(); ++i)
|
||||
if (layouts[i].convertible)
|
||||
{
|
||||
const auto &candidate = layouts[i];
|
||||
const bool tracked = layout && candidate.handle == layout;
|
||||
if (!candidate.convertible || (!tracked && fallback >= 0))
|
||||
continue;
|
||||
|
||||
std::wstring expected;
|
||||
for (wchar_t c : keys)
|
||||
expected += c == L' ' ? L' ' : candidate.at(physical.code(c));
|
||||
if (lower(expected) == normalized)
|
||||
{
|
||||
std::wstring expected;
|
||||
for (wchar_t c : keys)
|
||||
expected += c == L' ' ? L' ' : layouts[i].at(physical.code(c));
|
||||
if (lower(expected) == lower(text))
|
||||
if (tracked)
|
||||
return i;
|
||||
fallback = i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
} // namespace ks
|
||||
Reference in new issue
Block a user