use helpers to see if there is '}' already

This commit is contained in:
Nate Stemen 2018-01-18 10:25:19 -05:00
parent 08593f1f4b
commit d2adc753aa

View file

@ -1,4 +1,6 @@
define () ->
define [
"./Helpers"
], (Helpers) ->
packages = [
'inputenc', 'graphicx', 'amsmath', 'geometry', 'amssymb', 'hyperref',
'babel', 'color', 'xcolor', 'url', 'natbib', 'fontenc', 'fancyhdr',
@ -24,13 +26,14 @@ define () ->
constructor: (@metadataManager) ->
getCompletions: (editor, session, pos, prefix, callback) ->
{closingBrace} = Helpers.getContext(editor, pos)
usedPackages = Object.keys(@metadataManager.getAllPackages())
packageSnippets = []
for pkg in packages
if pkg not in usedPackages
packageSnippets.push {
caption: "\\usepackage{#{pkg}}"
snippet: "\\usepackage{#{pkg}}"
caption: "\\usepackage{#{pkg}#{closingBrace}"
snippet: "\\usepackage{#{pkg}#{closingBrace}"
meta: "pkg"
}