Explorar o código

Refactor 'async style'

Sebastien Lebreton %!s(int64=5) %!d(string=hai) anos
pai
achega
d6307fe495
Modificáronse 1 ficheiros con 13 adicións e 15 borrados
  1. 13 15
      Playground/js/monacoCreator.js

+ 13 - 15
Playground/js/monacoCreator.js

@@ -77,22 +77,20 @@ class MonacoCreator {
             return !suggestion.label.startsWith("_");
         }
 
-        provider.prototype.provideCompletionItems = function(model, position, context, token) {
+        provider.prototype.provideCompletionItems = async function(model, position, context, token) {
             // reuse 'this' to preserve context through call (using apply)
-            return hooked
-                .apply(this, [model, position, context, token])
-                .then(result => {
-                    if (!result || !result.suggestions)
-                        return result;
-
-                    const suggestions = result.suggestions.filter(suggestionFilter);
-                    const incomplete = result.incomplete && result.incomplete == true;
-
-                    return { 
-                        suggestions: suggestions,
-                        incomplete: incomplete
-                    };
-                });
+            var result = await hooked.apply(this, [model, position, context, token]);
+            
+            if (!result || !result.suggestions)
+                return result;
+
+            const suggestions = result.suggestions.filter(suggestionFilter);
+            const incomplete = result.incomplete && result.incomplete == true;
+
+            return { 
+                suggestions: suggestions,
+                incomplete: incomplete
+            };
         }
     }