Przeglądaj źródła

Merge pull request #6633 from overleaf/jk-cm6-spelling-ignore-commands

[web] Ace/CM6 Spelling: don't send commands to backend

GitOrigin-RevId: 7fbd14240facb71b6d110eb95e271b07fced76b1
June Kelly 4 lat temu
rodzic
commit
ab5135957a

+ 4 - 0
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)
         }

+ 3 - 1
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 () {