فهرست منبع

Parse `\newenvironment{}` commands.

Shane Kilkelly 10 سال پیش
والد
کامیت
c25c2b676a
1فایلهای تغییر یافته به همراه16 افزوده شده و 1 حذف شده
  1. 16 1
      services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SnippetManager.coffee

+ 16 - 1
services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SnippetManager.coffee

@@ -97,9 +97,24 @@ define () ->
 		meta: "env"
 		meta: "env"
 	}]
 	}]
 
 
+	CUSTOM_ENVIRONMENT_REGEX = /^\\newenvironment{(\w+)}.*$/gm
+
+	parseCustomEnvironmentNames = (text) ->
+		names = []
+		iterations = 0
+		while match = CUSTOM_ENVIRONMENT_REGEX.exec(text)
+			names.push match[1]
+			iterations += 1
+			if iterations >= 1000
+				return names
+		return names
+
 	class SnippetManager
 	class SnippetManager
 		getCompletions: (editor, session, pos, prefix, callback) ->
 		getCompletions: (editor, session, pos, prefix, callback) ->
-			console.log ">> get snippet completions"
+			# console.log ">> get snippet completions", editor, session, pos, prefix
+			docText = session.getValue()
+			customEnvironmentNames = parseCustomEnvironmentNames(docText)
+			# console.log customEnvironmentNames
 			callback null, staticSnippets
 			callback null, staticSnippets
 
 
 	return SnippetManager
 	return SnippetManager