mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Clearer logic for triggering labels-loading
This commit is contained in:
parent
0a491a4f13
commit
debb0c06a4
1 changed files with 5 additions and 5 deletions
|
@ -16,16 +16,16 @@ define [
|
||||||
onChange = (change) =>
|
onChange = (change) =>
|
||||||
if change.remote
|
if change.remote
|
||||||
return
|
return
|
||||||
|
if change.action not in ['remove', 'insert']
|
||||||
|
return
|
||||||
cursorPosition = @editor.getCursorPosition()
|
cursorPosition = @editor.getCursorPosition()
|
||||||
end = change.end
|
end = change.end
|
||||||
range = new Range(end.row, 0, end.row, end.column)
|
range = new Range(end.row, 0, end.row, end.column)
|
||||||
lineUpToCursor = @editor.getSession().getTextRange(range)
|
lineUpToCursor = @editor.getSession().getTextRange(range)
|
||||||
commandFragment = getLastCommandFragment(lineUpToCursor)
|
commandFragment = getLastCommandFragment(lineUpToCursor)
|
||||||
if (
|
linesContainLabel = _.any(change.lines, (line) -> line.match(/\\label\{[^\}\n\\]{0,80}\}/))
|
||||||
change.action in ['remove', 'insert'] and
|
lastCommandFragmentIsLabel = commandFragment?.slice(0,7) == '\\label{'
|
||||||
((_.any(change.lines, (line) -> line.match(/\\label\{[^\}\n\\]{0,80}\}/))) or
|
if linesContainLabel or lastCommandFragmentIsLabel
|
||||||
(commandFragment?.length > 2 and commandFragment.slice(0,7) == '\\label{'))
|
|
||||||
)
|
|
||||||
@scheduleLoadCurrentDocLabelsFromServer()
|
@scheduleLoadCurrentDocLabelsFromServer()
|
||||||
|
|
||||||
@editor.on "changeSession", (e) =>
|
@editor.on "changeSession", (e) =>
|
||||||
|
|
Loading…
Reference in a new issue