From ddc85fe192a99ac15aa12669bad3f4bc5361d3b4 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Thu, 10 Nov 2011 16:13:10 +0100 Subject: [PATCH] fakevim: improve reading of mappings from .vimrc Change-Id: I3a575ae71c3c84dea98e2d35d1eda429a3c1ea66 Reviewed-by: hjk <qthjk@ovi.com> --- src/plugins/fakevim/fakevimhandler.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index c2769fb94e2..e3faad1b833 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -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; -- GitLab