From 846f27f0adfcfa3d05360af3a892646a9b97efb2 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Tue, 15 May 2018 15:08:36 +0100 Subject: [PATCH] Clear highlights that are "touching" the cursor on change This means that correcting a mistake won't wait until the request has resolved and that only the word at the end of the line will have it's spelling highlight removed instead of the entire row --- .../spell-check/HighlightedWordManager.coffee | 21 +++++++++++++++++++ .../spell-check/SpellCheckManager.coffee | 3 +++ 2 files changed, 24 insertions(+) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/HighlightedWordManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/HighlightedWordManager.coffee index 46b7a218ab..8bb350914f 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/HighlightedWordManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/HighlightedWordManager.coffee @@ -67,3 +67,24 @@ define [ highlightRow > end.row or (highlightRow == end.row and highlightStartColumn >= end.column) !(highlightIsAllBeforeRange or highlightIsAllAfterRange) + + clearHighlightTouchingRange: (range) -> + highlight = @highlights.find (hl) => + @_doesHighlightTouchRange hl, range.start, range.end + if highlight + @removeHighlight highlight + + _doesHighlightTouchRange: (highlight, start, end) -> + highlightRow = highlight.range.start.row + highlightStartColumn = highlight.range.start.column + highlightEndColumn = highlight.range.end.column + + rangeStartIsWithinHighlight = + highlightStartColumn <= start.column and + highlightEndColumn >= start.column + rangeEndIsWithinHighlight = + highlightStartColumn <= end.column and + highlightEndColumn >= end.column + + highlightRow == start.row and + (rangeStartIsWithinHighlight or rangeEndIsWithinHighlight) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee index 6cc95d58c4..2828f4b426 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee @@ -35,6 +35,9 @@ define [], () -> onChange: (e) => if @isSpellCheckEnabled() @markLinesAsUpdated(@adapter.normalizeChangeEvent(e)) + + @adapter.wordManager.clearHighlightTouchingRange(e) + @runSpellCheckSoon() onSessionChange: () =>