mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-17 05:42:35 +00:00
Merge branch 'ns-fix-package-command-meta'
This commit is contained in:
commit
c43aa54bee
1 changed files with 6 additions and 3 deletions
|
@ -2,8 +2,6 @@ define [
|
||||||
"./top_hundred_snippets"
|
"./top_hundred_snippets"
|
||||||
], (topHundred) ->
|
], (topHundred) ->
|
||||||
|
|
||||||
commandNames = (snippet.caption.match(/\w+/)[0] for snippet in topHundred)
|
|
||||||
|
|
||||||
class Parser
|
class Parser
|
||||||
constructor: (@doc, @prefix) ->
|
constructor: (@doc, @prefix) ->
|
||||||
|
|
||||||
|
@ -96,18 +94,23 @@ define [
|
||||||
constructor: (@metadataManager) ->
|
constructor: (@metadataManager) ->
|
||||||
|
|
||||||
getCompletions: (editor, session, pos, prefix, callback) ->
|
getCompletions: (editor, session, pos, prefix, callback) ->
|
||||||
|
commandNames = {}
|
||||||
|
for snippet in topHundred
|
||||||
|
commandNames[snippet.caption.match(/\w+/)[0]] = true
|
||||||
|
|
||||||
packages = @metadataManager.getAllPackages()
|
packages = @metadataManager.getAllPackages()
|
||||||
packageCommands = []
|
packageCommands = []
|
||||||
for pkg, snippets of packages
|
for pkg, snippets of packages
|
||||||
for snippet in snippets
|
for snippet in snippets
|
||||||
packageCommands.push snippet
|
packageCommands.push snippet
|
||||||
|
commandNames[snippet.caption.match(/\w+/)[0]] = true
|
||||||
|
|
||||||
doc = session.getValue()
|
doc = session.getValue()
|
||||||
parser = new Parser(doc, prefix)
|
parser = new Parser(doc, prefix)
|
||||||
commands = parser.parse()
|
commands = parser.parse()
|
||||||
completions = []
|
completions = []
|
||||||
for command in commands
|
for command in commands
|
||||||
if command[0] not in commandNames
|
if not commandNames[command[0]]
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue