Handle cite commands like citep and citet, etc.

This commit is contained in:
Shane Kilkelly 2016-02-03 15:08:52 +00:00
parent 7fceb2b3af
commit 7ef96be7dc

View file

@ -12,10 +12,10 @@ define [
else else
return null return null
referenceKeyToAutocompleteEntry = (key) -> referenceKeyToAutocompleteEntry = (commandName, key) ->
return { return {
caption: "\\cite{#{key}", caption: "\\#{commandName}{#{key}",
snippet: "\\cite{#{key}", snippet: "\\#{commandName}{#{key}",
meta: "reference", meta: "reference",
score: 10000 score: 10000
} }
@ -56,17 +56,20 @@ define [
range = new Range(pos.row, 0, pos.row, pos.column) range = new Range(pos.row, 0, pos.row, pos.column)
lineUpToCursor = editor.getSession().getTextRange(range) lineUpToCursor = editor.getSession().getTextRange(range)
commandFragment = getLastCommandFragment(lineUpToCursor) commandFragment = getLastCommandFragment(lineUpToCursor)
if commandFragment and commandFragment.match(/^~?\\cite{\w*/) if commandFragment
citeMatch = commandFragment.match(/^~?\\(cite[a-z]?){\w*/)
if citeMatch
commandName = citeMatch[1]
result = [] result = []
result.push { result.push {
caption: "\\cite{", caption: "\\#{commandName}{",
snippet: "\\cite{", snippet: "\\#{commandName}{",
meta: "reference", meta: "reference",
score: 11000 score: 11000
} }
if references.keys and references.keys.length > 0 if references.keys and references.keys.length > 0
references.keys.forEach (key) -> references.keys.forEach (key) ->
result.push(referenceKeyToAutocompleteEntry(key)) result.push(referenceKeyToAutocompleteEntry(commandName, key))
callback null, result callback null, result
else else
callback null, result callback null, result