diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-10-30 21:56:42 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2021-10-31 19:26:15 +0100 |
commit | 8c90023676fae675e89b1a20c7fc95c63fc1dd5a (patch) | |
tree | cef3c3f6716026d1e9998fec8ca9171c6fe478af /language-web/src/main/js/xtext/HighlightingService.ts | |
parent | feat(web): use 4 space for indentation (diff) | |
download | refinery-8c90023676fae675e89b1a20c7fc95c63fc1dd5a.tar.gz refinery-8c90023676fae675e89b1a20c7fc95c63fc1dd5a.tar.zst refinery-8c90023676fae675e89b1a20c7fc95c63fc1dd5a.zip |
feat(web): find occurrences when idle
Diffstat (limited to 'language-web/src/main/js/xtext/HighlightingService.ts')
-rw-r--r-- | language-web/src/main/js/xtext/HighlightingService.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/language-web/src/main/js/xtext/HighlightingService.ts b/language-web/src/main/js/xtext/HighlightingService.ts index b8ceed20..451a3a52 100644 --- a/language-web/src/main/js/xtext/HighlightingService.ts +++ b/language-web/src/main/js/xtext/HighlightingService.ts | |||
@@ -1,7 +1,5 @@ | |||
1 | import { Decoration } from '@codemirror/view'; | ||
2 | import { Range, RangeSet } from '@codemirror/rangeset'; | ||
3 | |||
4 | import type { EditorStore } from '../editor/EditorStore'; | 1 | import type { EditorStore } from '../editor/EditorStore'; |
2 | import type { IHighlightRange } from '../editor/semanticHighlighting'; | ||
5 | import type { UpdateService } from './UpdateService'; | 3 | import type { UpdateService } from './UpdateService'; |
6 | import { getLogger } from '../utils/logger'; | 4 | import { getLogger } from '../utils/logger'; |
7 | import { isHighlightingResult } from './xtextServiceResults'; | 5 | import { isHighlightingResult } from './xtextServiceResults'; |
@@ -24,7 +22,7 @@ export class HighlightingService { | |||
24 | return; | 22 | return; |
25 | } | 23 | } |
26 | const allChanges = this.updateService.computeChangesSinceLastUpdate(); | 24 | const allChanges = this.updateService.computeChangesSinceLastUpdate(); |
27 | const decorations: Range<Decoration>[] = []; | 25 | const ranges: IHighlightRange[] = []; |
28 | push.regions.forEach(({ offset, length, styleClasses }) => { | 26 | push.regions.forEach(({ offset, length, styleClasses }) => { |
29 | if (styleClasses.length === 0) { | 27 | if (styleClasses.length === 0) { |
30 | return; | 28 | return; |
@@ -34,10 +32,12 @@ export class HighlightingService { | |||
34 | if (to <= from) { | 32 | if (to <= from) { |
35 | return; | 33 | return; |
36 | } | 34 | } |
37 | decorations.push(Decoration.mark({ | 35 | ranges.push({ |
38 | class: styleClasses.map((c) => `cmt-problem-${c}`).join(' '), | 36 | from, |
39 | }).range(from, to)); | 37 | to, |
38 | classes: styleClasses, | ||
39 | }); | ||
40 | }); | 40 | }); |
41 | this.store.updateSemanticHighlighting(RangeSet.of(decorations, true)); | 41 | this.store.updateSemanticHighlighting(ranges); |
42 | } | 42 | } |
43 | } | 43 | } |