From 8b4843cf8b655eb8798a4604f0862983f3374292 Mon Sep 17 00:00:00 2001 From: Nate Stemen Date: Tue, 3 Oct 2017 17:32:34 +0100 Subject: [PATCH] cleaning up usepackage completion --- .../auto-complete/CommandManager.coffee | 4 ++-- .../auto-complete/PackageManager.coffee | 20 ++++++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee index c513f6854d..88cd3a2e84 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee @@ -12,7 +12,7 @@ define [], () -> 'Lambda', 'Xi', 'Pi', 'Sigma', 'Upsilon', 'Phi', 'Psi', 'Omega' ] singleArgumentCommands = [ - 'chapter', 'usepackage', 'section', 'label', 'textbf', 'subsection', + 'chapter', 'section', 'label', 'textbf', 'subsection', 'vspace', 'cite', 'textit', 'documentclass', 'includegraphics', 'input', 'emph','caption', 'ref', 'title', 'author', 'texttt', 'include', 'hspace', 'bibitem', 'url', 'large', 'subsubsection', 'textsc', 'date', @@ -172,7 +172,7 @@ define [], () -> commands = parser.parse() completions = [] for command in commands - if command[0] not in rawCommands + if command[0] not in rawCommands and command[0] != "usepackage" caption = "\\#{command[0]}" score = if caption == prefix then 99 else 50 snippet = caption diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/PackageManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/PackageManager.coffee index af8cac861a..ac30d5a431 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/PackageManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/PackageManager.coffee @@ -27,20 +27,12 @@ define () -> meta: "pkg" } - parseLoadedPackages = (text) -> - re = /^\\usepackage(?:\[(.*?)])?.*?{((?:.|\n)*?)}/gm - result = [] - iterations = 0 - while match = re.exec(text) - 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 + packageSnippets.push { + caption: "\\usepackage{}" + snippet: "\\usepackage{}" + meta: "pkg" + score: 70 + } class PackageManager getCompletions: (editor, session, pos, prefix, callback) ->