mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Support variations of \ref{}
, such as \cref{}
, \eqref{}
, etc..
This commit is contained in:
parent
b0ff8e0745
commit
3f1a440d66
1 changed files with 7 additions and 6 deletions
|
@ -47,23 +47,24 @@ define [
|
||||||
lineUpToCursor = editor.getSession().getTextRange(upToCursorRange)
|
lineUpToCursor = editor.getSession().getTextRange(upToCursorRange)
|
||||||
commandFragment = getLastCommandFragment(lineUpToCursor)
|
commandFragment = getLastCommandFragment(lineUpToCursor)
|
||||||
if commandFragment
|
if commandFragment
|
||||||
refMatch = commandFragment.match(/^~?\\ref{([^}]*, *)?(\w*)/)
|
refMatch = commandFragment.match(/^~?\\([a-z]*ref){([^}]*, *)?(\w*)/)
|
||||||
if refMatch
|
if refMatch
|
||||||
beyondCursorRange = new Range(pos.row, pos.column, pos.row, 99999)
|
beyondCursorRange = new Range(pos.row, pos.column, pos.row, 99999)
|
||||||
lineBeyondCursor = editor.getSession().getTextRange(beyondCursorRange)
|
lineBeyondCursor = editor.getSession().getTextRange(beyondCursorRange)
|
||||||
needsClosingBrace = !lineBeyondCursor.match(/^[^{]*}/)
|
needsClosingBrace = !lineBeyondCursor.match(/^[^{]*}/)
|
||||||
currentArg = refMatch[1]
|
commandName = refMatch[1]
|
||||||
|
currentArg = refMatch[2]
|
||||||
result = []
|
result = []
|
||||||
result.push {
|
result.push {
|
||||||
caption: "\\ref{}",
|
caption: "\\#{commandName}{}",
|
||||||
snippet: "\\ref{}",
|
snippet: "\\#{commandName}{}",
|
||||||
meta: "cross-reference",
|
meta: "cross-reference",
|
||||||
score: 11000
|
score: 11000
|
||||||
}
|
}
|
||||||
for label in labelsManager.getAllLabels()
|
for label in labelsManager.getAllLabels()
|
||||||
result.push {
|
result.push {
|
||||||
caption: "\\ref{#{label}#{if needsClosingBrace then '}' else ''}",
|
caption: "\\#{commandName}{#{label}#{if needsClosingBrace then '}' else ''}",
|
||||||
value: "\\ref{#{label}#{if needsClosingBrace then '}' else ''}",
|
value: "\\#{commandName}{#{label}#{if needsClosingBrace then '}' else ''}",
|
||||||
meta: "cross-reference",
|
meta: "cross-reference",
|
||||||
score: 10000
|
score: 10000
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue