From 039d18bf8ba1afebdbffba6e43f76af392b89d7e Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 26 May 2017 15:08:38 +0100 Subject: [PATCH] Simplify logic for deciding whether to re-scan doc on not --- .../aceEditor/labels/LabelsManager.coffee | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/labels/LabelsManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/labels/LabelsManager.coffee index 860147a3fb..631e23bc82 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/labels/LabelsManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/labels/LabelsManager.coffee @@ -23,20 +23,12 @@ define [ range = new Range(end.row, 0, end.row, end.column) lineUpToCursor = @editor.getSession().getTextRange(range) commandFragment = getLastCommandFragment(lineUpToCursor) - if change.action == 'remove' - if _.any(change.lines, (line) -> line.match(/\\label\{[^\}\n\\]{0,80}\}/)) - @scheduleLoadLabelsFromOpenDoc() - if commandFragment? and commandFragment.length > 2 - if commandFragment.startsWith('\\label{') - @scheduleLoadLabelsFromOpenDoc() if ( - change.action == "insert" and - end.row == cursorPosition.row and - end.column == cursorPosition.column + 1 + change.action in ['remove', 'insert'] and + ((_.any(change.lines, (line) -> line.match(/\\label\{[^\}\n\\]{0,80}\}/))) or + (commandFragment?.length > 2 and commandFragment.startsWith('\\label{'))) ) - if commandFragment? and commandFragment.length > 2 - if commandFragment.startsWith('\\label{') - @scheduleLoadLabelsFromOpenDoc() + @scheduleLoadLabelsFromOpenDoc() @editor.on "changeSession", (e) => e.oldSession.off "change", onChange