mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
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
This commit is contained in:
parent
2be023c731
commit
846f27f0ad
2 changed files with 24 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -35,6 +35,9 @@ define [], () ->
|
|||
onChange: (e) =>
|
||||
if @isSpellCheckEnabled()
|
||||
@markLinesAsUpdated(@adapter.normalizeChangeEvent(e))
|
||||
|
||||
@adapter.wordManager.clearHighlightTouchingRange(e)
|
||||
|
||||
@runSpellCheckSoon()
|
||||
|
||||
onSessionChange: () =>
|
||||
|
|
Loading…
Reference in a new issue