mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-20 04:23:59 +00:00
Autocomplete with many parameters to cite
.
This commit is contained in:
parent
7ef96be7dc
commit
90fd6eb8a1
1 changed files with 11 additions and 10 deletions
|
@ -12,14 +12,6 @@ define [
|
||||||
else
|
else
|
||||||
return null
|
return null
|
||||||
|
|
||||||
referenceKeyToAutocompleteEntry = (commandName, key) ->
|
|
||||||
return {
|
|
||||||
caption: "\\#{commandName}{#{key}",
|
|
||||||
snippet: "\\#{commandName}{#{key}",
|
|
||||||
meta: "reference",
|
|
||||||
score: 10000
|
|
||||||
}
|
|
||||||
|
|
||||||
class AutoCompleteManager
|
class AutoCompleteManager
|
||||||
constructor: (@$scope, @editor) ->
|
constructor: (@$scope, @editor) ->
|
||||||
@suggestionManager = new SuggestionManager()
|
@suggestionManager = new SuggestionManager()
|
||||||
|
@ -57,9 +49,13 @@ define [
|
||||||
lineUpToCursor = editor.getSession().getTextRange(range)
|
lineUpToCursor = editor.getSession().getTextRange(range)
|
||||||
commandFragment = getLastCommandFragment(lineUpToCursor)
|
commandFragment = getLastCommandFragment(lineUpToCursor)
|
||||||
if commandFragment
|
if commandFragment
|
||||||
citeMatch = commandFragment.match(/^~?\\(cite[a-z]?){\w*/)
|
citeMatch = commandFragment.match(/^~?\\(cite[a-z]?){(.*,)?(\w*)/)
|
||||||
if citeMatch
|
if citeMatch
|
||||||
commandName = citeMatch[1]
|
commandName = citeMatch[1]
|
||||||
|
previousArgs = citeMatch[2]
|
||||||
|
currentArg = citeMatch[3]
|
||||||
|
if previousArgs == undefined
|
||||||
|
previousArgs = ""
|
||||||
result = []
|
result = []
|
||||||
result.push {
|
result.push {
|
||||||
caption: "\\#{commandName}{",
|
caption: "\\#{commandName}{",
|
||||||
|
@ -69,7 +65,12 @@ define [
|
||||||
}
|
}
|
||||||
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(commandName, key))
|
result.push({
|
||||||
|
caption: "\\#{commandName}{#{previousArgs}#{key}",
|
||||||
|
snippet: "\\#{commandName}{#{previousArgs}#{key}",
|
||||||
|
meta: "reference",
|
||||||
|
score: 10000
|
||||||
|
})
|
||||||
callback null, result
|
callback null, result
|
||||||
else
|
else
|
||||||
callback null, result
|
callback null, result
|
||||||
|
|
Loading…
Reference in a new issue