Преглед на файлове

[bugfix] initialize selection if root items are differents was wrong

isundil преди 9 години
родител
ревизия
55a4cc7c9e
променени са 3 файла, в които са добавени 10 реда и са изтрити 22 реда
  1. 0 1
      include/levenshteinMatrice.hpp
  2. 2 1
      src/curseSplitOutput.cpp
  3. 8 20
      src/levenshtein.cpp

+ 0 - 1
include/levenshteinMatrice.hpp

@@ -47,7 +47,6 @@ class LevenshteinMatrice_manual: public LevenshteinMatrice_base
 class LevenshteinMatriceWithScore: public LevenshteinMatrice_base
 {
     public:
-        LevenshteinMatriceWithScore(float score, const JSonElement *a, const JSonElement *b);
         LevenshteinMatriceWithScore(float score, const JSonElement *a, const JSonElement *b, bool sameType);
 
         std::map<const JSonElement *, const JSonElement *> getEquivalences() const;

+ 2 - 1
src/curseSplitOutput.cpp

@@ -52,7 +52,7 @@ void CurseSplitOutput::run(const std::deque<std::string> &inputName, const std::
         t_subWindow subwin;
 
         subwin.fileName = inputName.at(i);
-        subwin.selection = subwin.lastSelection = subwin.root = roots.at(i);
+        subwin.lastSelection = subwin.root = roots.at(i);
         subwin.select_up = subwin.select_down = nullptr;
         subwin.innerWin = subwin.outerWin = nullptr;
         subwin.scrollTop = 0;
@@ -64,6 +64,7 @@ void CurseSplitOutput::run(const std::deque<std::string> &inputName, const std::
         wrefresh(subwin.outerWin);
     }
     computeDiff();
+    setSelection(subWindows.at(0).lastSelection);
     loop(subWindows.at(0).outerWin);
 }
 

+ 8 - 20
src/levenshtein.cpp

@@ -93,11 +93,12 @@ LevenshteinMatrice_base *LevenshteinMatrice_base::Builder::build(const JSonEleme
         {
             if (a->stringify() == b->stringify())
                 return LevenshteinMatrice_base::Builder::build(*(const JSonObjectEntry&)(*a), *(const JSonObjectEntry&)(*b));
-            return new LevenshteinMatriceWithScore(0.f, a, b);
+            return new LevenshteinMatriceWithScore(0.f, a, b, true);
         }
         else if (aIsObject || bIsObject)
-            return new LevenshteinMatriceWithScore(0.f, a, b);
-        return new LevenshteinMatriceWithScore(levenshteinPercent(a->stringify(), b->stringify()), a, b, ((const AJSonPrimitive*)a)->sameType((const AJSonPrimitive *)b));
+            return new LevenshteinMatriceWithScore(0.f, a, b, false);
+        return new LevenshteinMatriceWithScore(levenshteinPercent(a->stringify(), b->stringify()),
+                a, b, ((const AJSonPrimitive*)a)->sameType((const AJSonPrimitive *)b));
     }
 }
 
@@ -167,33 +168,20 @@ bool LevenshteinMatrice_manual::areSimilar() const
 /**
  * Score matrice
 **/
-LevenshteinMatriceWithScore::LevenshteinMatriceWithScore(float s, const JSonElement *a, const JSonElement *b)
-{
-    _result = s > LEVENSHTEIN_SENSIBILITY;
-    if (_result)
-    {
-        equivalentA = a;
-        equivalentB = b;
-    }
-    else
-        equivalentA = equivalentB = nullptr;
-    operations[a] = operations[b] = (_result ? eLevenshteinOperator::equ : eLevenshteinOperator::add);
-}
-
 LevenshteinMatriceWithScore::LevenshteinMatriceWithScore(float s, const JSonElement *a, const JSonElement *b, bool sameType)
 {
     _result = s > LEVENSHTEIN_SENSIBILITY;
-    if (_result)
+    if (sameType)
     {
         equivalentA = a;
         equivalentB = b;
     }
     else
         equivalentA = equivalentB = nullptr;
-    if (_result)
-        operations[a] = operations[b] = (sameType ? eLevenshteinOperator::equ : eLevenshteinOperator::mod);
+    if (sameType)
+        operations[a] = operations[b] = (_result ? eLevenshteinOperator::equ : eLevenshteinOperator::mod);
     else
-        operations[a] = operations[b] = eLevenshteinOperator::mod;
+        operations[a] = operations[b] = eLevenshteinOperator::add;
 }
 
 const JSonElement * LevenshteinMatriceWithScore::getEquivalence(const JSonElement *a) const