mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
cleaning up usepackage completion
This commit is contained in:
parent
7d5785b98f
commit
8b4843cf8b
2 changed files with 8 additions and 16 deletions
|
@ -12,7 +12,7 @@ define [], () ->
|
||||||
'Lambda', 'Xi', 'Pi', 'Sigma', 'Upsilon', 'Phi', 'Psi', 'Omega'
|
'Lambda', 'Xi', 'Pi', 'Sigma', 'Upsilon', 'Phi', 'Psi', 'Omega'
|
||||||
]
|
]
|
||||||
singleArgumentCommands = [
|
singleArgumentCommands = [
|
||||||
'chapter', 'usepackage', 'section', 'label', 'textbf', 'subsection',
|
'chapter', 'section', 'label', 'textbf', 'subsection',
|
||||||
'vspace', 'cite', 'textit', 'documentclass', 'includegraphics', 'input',
|
'vspace', 'cite', 'textit', 'documentclass', 'includegraphics', 'input',
|
||||||
'emph','caption', 'ref', 'title', 'author', 'texttt', 'include',
|
'emph','caption', 'ref', 'title', 'author', 'texttt', 'include',
|
||||||
'hspace', 'bibitem', 'url', 'large', 'subsubsection', 'textsc', 'date',
|
'hspace', 'bibitem', 'url', 'large', 'subsubsection', 'textsc', 'date',
|
||||||
|
@ -172,7 +172,7 @@ define [], () ->
|
||||||
commands = parser.parse()
|
commands = parser.parse()
|
||||||
completions = []
|
completions = []
|
||||||
for command in commands
|
for command in commands
|
||||||
if command[0] not in rawCommands
|
if command[0] not in rawCommands and command[0] != "usepackage"
|
||||||
caption = "\\#{command[0]}"
|
caption = "\\#{command[0]}"
|
||||||
score = if caption == prefix then 99 else 50
|
score = if caption == prefix then 99 else 50
|
||||||
snippet = caption
|
snippet = caption
|
||||||
|
|
|
@ -27,20 +27,12 @@ define () ->
|
||||||
meta: "pkg"
|
meta: "pkg"
|
||||||
}
|
}
|
||||||
|
|
||||||
parseLoadedPackages = (text) ->
|
packageSnippets.push {
|
||||||
re = /^\\usepackage(?:\[(.*?)])?.*?{((?:.|\n)*?)}/gm
|
caption: "\\usepackage{}"
|
||||||
result = []
|
snippet: "\\usepackage{}"
|
||||||
iterations = 0
|
meta: "pkg"
|
||||||
while match = re.exec(text)
|
score: 70
|
||||||
if match[2]
|
}
|
||||||
for pkg in match[2].split(",")
|
|
||||||
cleaned = pkg.replace(/%.*\n/gm,'').trim()
|
|
||||||
if cleaned not in result
|
|
||||||
result.push cleaned
|
|
||||||
iterations += 1
|
|
||||||
if iterations >= 1000
|
|
||||||
return result
|
|
||||||
return result
|
|
||||||
|
|
||||||
class PackageManager
|
class PackageManager
|
||||||
getCompletions: (editor, session, pos, prefix, callback) ->
|
getCompletions: (editor, session, pos, prefix, callback) ->
|
||||||
|
|
Loading…
Reference in a new issue