 
 			GraphicsCompleter =
 				getCompletions: (editor, session, pos, prefix, callback) ->
-					context = Helpers.getContext(editor, pos)
-					{commandFragment, closingBrace} = context
+					{commandFragment, closingBrace} = Helpers.getContext(editor, pos)
 					if commandFragment
 						match = commandFragment.match(/^~?\\(includegraphics(?:\[.*])?){([^}]*, *)?(\w*)/)
 						if match
-							commandName = match[1]
-							currentArg = match[3]
+							[commandName, _, currentArg] = match
 							graphicsPaths = Preamble.getGraphicsPaths()
 							result = []
 							for graphic in Graphics.getGraphicsFiles()

			metadataManager = @metadataManager
			FilesCompleter =
				getCompletions: (editor, session, pos, prefix, callback) =>
					context = Helpers.getContext(editor, pos)
					{commandFragment, closingBrace} = context
					if commandFragment
						match = commandFragment.match(/^\\(input|include){(\w*)/)
						if match
							commandName = match[1]
							currentArg = match[2]
							result = []
							for file in Files.getTeXFiles()
								if file.id != @$scope.docId


			LabelsCompleter =
				getCompletions: (editor, session, pos, prefix, callback) ->
					{commandFragment, closingBrace} = Helpers.getContext(editor, pos)
					if commandFragment
						refMatch = commandFragment.match(/^~?\\([a-z]*ref){([^}]*, *)?(\w*)/)
						if refMatch
							[commandName, currentArg] = refMatch
							result = []
							if commandName != 'ref' # ref is in top 100 commands
								result.push {
