Ver Fonte

Fix more bugs in and exposed by the tests.

Jason Grout há 4 anos atrás
pai
commit
495369d011
2 ficheiros alterados com 23 adições e 13 exclusões
  1. 9 11
      packages/completer/src/model.ts
  2. 14 2
      packages/completer/test/model.spec.ts

+ 9 - 11
packages/completer/src/model.ts

@@ -414,25 +414,23 @@ export class CompleterModel implements Completer.IModel {
           Private.mark
         );
         results.push({
+          ...item,
           label: marked.join(''),
           // If no insertText is present, preserve original label value
           // by setting it as the insertText.
           insertText: item.insertText ? item.insertText : item.label,
-          type: item.type,
-          icon: item.icon,
-          documentation: item.documentation,
-          deprecated: item.deprecated,
           score: match.score
         });
       }
-      results.sort(Private.scoreCmp2);
-
-      // Delete the extra score attribute to not leak implementation details
-      // to JavaScript callers.
-      results.forEach(x => {
-        delete (x as any).score;
-      });
     }
+    results.sort(Private.scoreCmp2);
+
+    // Delete the extra score attribute to not leak implementation details
+    // to JavaScript callers.
+    results.forEach(x => {
+      delete (x as any).score;
+    });
+
     return results;
   }
 

+ 14 - 2
packages/completer/test/model.spec.ts

@@ -220,7 +220,13 @@ describe('completer/model', () => {
           { insertText: 'qux', label: '<mark>qux</mark>' },
           { insertText: 'quux', label: '<mark>qu</mark>u<mark>x</mark>' }
         ];
-        model.setOptions(['foo', 'bar', 'baz', 'quux', 'qux']);
+        model.setCompletionItems!([
+          { label: 'foo' },
+          { label: 'bar' },
+          { label: 'baz' },
+          { label: 'quux' },
+          { label: 'qux' }
+        ]);
         model.query = 'qux';
         expect(model.completionItems!()).toEqual(want);
       });
@@ -231,7 +237,13 @@ describe('completer/model', () => {
           { insertText: 'quux', label: '<mark>qu</mark>ux' },
           { insertText: 'qux', label: '<mark>qu</mark>x' }
         ];
-        model.setOptions(['foo', 'bar', 'baz', 'qux', 'quux']);
+        model.setCompletionItems!([
+          { label: 'foo' },
+          { label: 'bar' },
+          { label: 'baz' },
+          { label: 'quux' },
+          { label: 'qux' }
+        ]);
         model.query = 'qu';
         expect(model.completionItems!()).toEqual(want);
       });