Commits

Ivan Vučica committed 033641b

Seemingly nicer prioritization when auto completing.

Comments (0)

Files changed (1)

Editor Teksta/IVSourceCodeDocument.m

         
     }
     
-    [ma sortUsingDescriptors:[NSArray arrayWithObject:
-                              [NSSortDescriptor sortDescriptorWithKey:@"priority" ascending:YES]]];
+    /*
+    {
+        NSMutableArray * ma2 = [ma mutableCopy];
+        [ma2 sortUsingDescriptors:[NSArray arrayWithObject:
+                                   [NSSortDescriptor sortDescriptorWithKey:@"priority" ascending:YES]]];
+        
+        bestPriority = [[[ma2 objectAtIndex:0] valueForKey:@"priority"] intValue];
+    }
+     */
     
-    bestPriority = [[[ma objectAtIndex:0] valueForKey:@"priority"] intValue];
     NSMutableArray * ourWords = [NSMutableArray arrayWithCapacity:ma.count];
     
     for(int i = 0 ; i < ma.count; i++)
         
         if(((word.length >= charRange.length && [[word substringToIndex:charRange.length] isEqualToString:[self.content.string substringWithRange:charRange]]) || charRange.length == 0))
         {
+            /*
             if(ourWords.count && word.length <= [[ourWords objectAtIndex:bestIndex] length])
                 bestIndex = ourWords.count;
+             */
+            if(priority < bestPriority)
+            {
+                bestPriority = priority;
+                bestIndex = ourWords.count;
+            }
             [ourWords addObject:word];
         }
     }