load the keys if the command is a 'cite'

This commit is contained in:
Shane Kilkelly 2015-12-29 15:48:42 +00:00
parent e94863d026
commit b0f3d9e6f4

View file

@ -46,14 +46,22 @@ define [
ReferencesCompleter = ReferencesCompleter =
getCompletions: (editor, session, pos, prefix, callback) -> getCompletions: (editor, session, pos, prefix, callback) ->
if references.keys if references.keys
range = new Range(pos.row, 0, pos.row, pos.column)
lineUpToCursor = editor.getSession().getTextRange(range)
commandFragment = getLastCommandFragment(lineUpToCursor)
console.log commandFragment
if commandFragment == '\\cite{'
console.log ">> yes"
result = references.keys.map (key) -> { result = references.keys.map (key) -> {
caption: key, caption: key,
snippet: key, snippet: key,
meta: "reference", meta: "reference",
score: 10000 score: 10000
} }
console.log result console.log ">> reference keys #{result.length}"
callback null, result callback null, result
else
callback null, []
@editor.completers = [@suggestionManager, SnippetCompleter, ReferencesCompleter] @editor.completers = [@suggestionManager, SnippetCompleter, ReferencesCompleter]