From ab5135957af71d453afbba47bcfc4086c8874c34 Mon Sep 17 00:00:00 2001 From: June Kelly Date: Tue, 8 Feb 2022 09:22:14 +0000 Subject: [PATCH] Merge pull request #6633 from overleaf/jk-cm6-spelling-ignore-commands [web] Ace/CM6 Spelling: don't send commands to backend GitOrigin-RevId: 7fbd14240facb71b6d110eb95e271b07fced76b1 --- .../directives/aceEditor/spell-check/SpellCheckManager.js | 4 ++++ .../editor/aceEditor/spell-check/SpellCheckManagerTests.js | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js b/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js index 4610cccd00..bc79bd028e 100644 --- a/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js +++ b/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js @@ -389,6 +389,10 @@ class SpellCheckManager { WORD_REGEX.lastIndex = 0 // reset global stateful regexp for this usage while ((result = WORD_REGEX.exec(line))) { let word = result[0] + // Skip latex commands, as they are ignored by the backend anyway + if (word.slice(0, 1) === '\\') { + continue + } if (word[0] === "'") { word = word.slice(1) } diff --git a/services/web/test/karma/ide/editor/aceEditor/spell-check/SpellCheckManagerTests.js b/services/web/test/karma/ide/editor/aceEditor/spell-check/SpellCheckManagerTests.js index 9e17e04027..1e30e2e309 100644 --- a/services/web/test/karma/ide/editor/aceEditor/spell-check/SpellCheckManagerTests.js +++ b/services/web/test/karma/ide/editor/aceEditor/spell-check/SpellCheckManagerTests.js @@ -206,7 +206,9 @@ export default describe('SpellCheckManager', function () { this.adapter.getLineCount.returns(1) this.adapter.getFirstVisibleRowNum.returns(1) this.adapter.getLastVisibleRowNum.returns(1) - this.adapter.getLinesByRows.returns(['Lorem ipsum dolor']) + this.adapter.getLinesByRows.returns([ + 'Lorem \\somecommand ipsum dolor \\othercommand', + ]) }) it('hits the backend with all words at startup', function () {