Commit ddc85fe1 authored by hjk's avatar hjk Committed by hjk
Browse files

fakevim: improve reading of mappings from .vimrc



Change-Id: I3a575ae71c3c84dea98e2d35d1eda429a3c1ea66
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 82f55736
......@@ -449,6 +449,12 @@ public:
&& m_text == a.m_text;
}
// Ignore e.g. ShiftModifier, which is not available in sourced data.
bool matchesForMap(const Input &a) const
{
return (a.m_key == m_key || a.m_xkey == m_xkey) && m_text == a.m_text;
}
bool operator!=(const Input &a) const { return !operator==(a); }
QString text() const { return m_text; }
......@@ -654,7 +660,7 @@ public:
for (int i = 0; i != size(); ++i) {
const Inputs &haystack = at(i).first;
// A mapping
if (startsWith(haystack, *inputs)) {
if (couldTriggerMap(haystack, *inputs)) {
if (haystack.size() != inputs->size())
return false; // This can be extended.
// Actual mapping.
......@@ -667,13 +673,13 @@ public:
}
private:
static bool startsWith(const Inputs &haystack, const Inputs &needle)
static bool couldTriggerMap(const Inputs &haystack, const Inputs &needle)
{
// Input is already too long.
if (needle.size() > haystack.size())
return false;
for (int i = 0; i != needle.size(); ++i) {
if (needle.at(i) != haystack.at(i))
if (!needle.at(i).matchesForMap(haystack.at(i)))
return false;
}
return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment