mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-25 02:00:55 +00:00
Merge branch 'sk-ref-variants'
This commit is contained in:
commit
b0bb4b3e47
1 changed files with 8 additions and 7 deletions
|
@ -42,28 +42,29 @@ define [
|
|||
|
||||
labelsManager = @labelsManager
|
||||
LabelsCompleter =
|
||||
getCompletions: (editor, session, pos, prefxi, callback) ->
|
||||
getCompletions: (editor, session, pos, prefix, callback) ->
|
||||
upToCursorRange = new Range(pos.row, 0, pos.row, pos.column)
|
||||
lineUpToCursor = editor.getSession().getTextRange(upToCursorRange)
|
||||
commandFragment = getLastCommandFragment(lineUpToCursor)
|
||||
if commandFragment
|
||||
refMatch = commandFragment.match(/^~?\\ref{([^}]*, *)?(\w*)/)
|
||||
refMatch = commandFragment.match(/^~?\\([a-z]*ref){([^}]*, *)?(\w*)/)
|
||||
if refMatch
|
||||
beyondCursorRange = new Range(pos.row, pos.column, pos.row, 99999)
|
||||
lineBeyondCursor = editor.getSession().getTextRange(beyondCursorRange)
|
||||
needsClosingBrace = !lineBeyondCursor.match(/^[^{]*}/)
|
||||
currentArg = refMatch[1]
|
||||
commandName = refMatch[1]
|
||||
currentArg = refMatch[2]
|
||||
result = []
|
||||
result.push {
|
||||
caption: "\\ref{}",
|
||||
snippet: "\\ref{}",
|
||||
caption: "\\#{commandName}{}",
|
||||
snippet: "\\#{commandName}{}",
|
||||
meta: "cross-reference",
|
||||
score: 11000
|
||||
}
|
||||
for label in labelsManager.getAllLabels()
|
||||
result.push {
|
||||
caption: "\\ref{#{label}#{if needsClosingBrace then '}' else ''}",
|
||||
value: "\\ref{#{label}#{if needsClosingBrace then '}' else ''}",
|
||||
caption: "\\#{commandName}{#{label}#{if needsClosingBrace then '}' else ''}",
|
||||
value: "\\#{commandName}{#{label}#{if needsClosingBrace then '}' else ''}",
|
||||
meta: "cross-reference",
|
||||
score: 10000
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue