Răsfoiți Sursa

Move the `getCompletions` call for Snippets into the Snippets module.

Shane Kilkelly 10 ani în urmă
părinte
comite
7cc3f7613e

+ 2 - 4
services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee

@@ -3,7 +3,7 @@ define [
 	"ide/editor/directives/aceEditor/auto-complete/Snippets"
 	"ace/ace"
 	"ace/ext-language_tools"
-], (SuggestionManager, Snippets) ->
+], (SuggestionManager, SnippetManager) ->
 	Range = ace.require("ace/range").Range
 
 	getLastCommandFragment = (lineUpToCursor) ->
@@ -38,9 +38,7 @@ define [
 				enableLiveAutocompletion: false
 			})
 
-			SnippetCompleter =
-				getCompletions: (editor, session, pos, prefix, callback) ->
-					callback null, Snippets
+			SnippetCompleter = new SnippetManager()
 
 			references = @$scope.$root._references
 			ReferencesCompleter =

+ 6 - 2
services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/Snippets.coffee

@@ -1,6 +1,6 @@
 define () ->
 	environments = [
-		"abstract", 
+		"abstract",
 		"align", "align*",
 		"equation", "equation*",
 		"gather", "gather*",
@@ -96,5 +96,9 @@ define () ->
 		"""
 		meta: "env"
 	}]
+	class SnippetManager
+		getCompletions: (editor, session, pos, prefix, callback) ->
+			console.log ">> get snippet completions"
+			callback null, snippets
 
-	return snippets
+	return SnippetManager

+ 1 - 2
services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee

@@ -28,7 +28,7 @@ define [], () ->
 
 		# Ignore single letter commands since auto complete is moot then.
 		commandRegex: /\\([a-zA-Z][a-zA-Z]+)/
-		
+
 		nextCommand: () ->
 			i = @doc.search(@commandRegex)
 			if i == -1
@@ -123,4 +123,3 @@ define [], () ->
 					completionBeforeCursor: completionBeforeCursor
 					completionAfterCursor: completionAfterCursor
 				}
-