diff options
Diffstat (limited to 'subprojects/frontend/src/editor/semanticHighlighting.ts')
-rw-r--r-- | subprojects/frontend/src/editor/semanticHighlighting.ts | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/subprojects/frontend/src/editor/semanticHighlighting.ts b/subprojects/frontend/src/editor/semanticHighlighting.ts index a5d0af7a..2c1bd67d 100644 --- a/subprojects/frontend/src/editor/semanticHighlighting.ts +++ b/subprojects/frontend/src/editor/semanticHighlighting.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { RangeSet, type TransactionSpec } from '@codemirror/state'; | 1 | import { RangeSet, type TransactionSpec } from '@codemirror/state'; |
2 | import { Decoration } from '@codemirror/view'; | 2 | import { Decoration } from '@codemirror/view'; |
3 | 3 | ||
4 | import { decorationSetExtension } from './decorationSetExtension'; | 4 | import defineDecorationSetExtension from './defineDecorationSetExtension'; |
5 | 5 | ||
6 | export interface IHighlightRange { | 6 | export interface IHighlightRange { |
7 | from: number; | 7 | from: number; |
@@ -11,13 +11,21 @@ export interface IHighlightRange { | |||
11 | classes: string[]; | 11 | classes: string[]; |
12 | } | 12 | } |
13 | 13 | ||
14 | const [setSemanticHighlightingInternal, semanticHighlighting] = decorationSetExtension(); | 14 | const [setSemanticHighlightingInternal, semanticHighlighting] = |
15 | defineDecorationSetExtension(); | ||
15 | 16 | ||
16 | export function setSemanticHighlighting(ranges: IHighlightRange[]): TransactionSpec { | 17 | export function setSemanticHighlighting( |
17 | const rangeSet = RangeSet.of(ranges.map(({ from, to, classes }) => Decoration.mark({ | 18 | ranges: IHighlightRange[], |
18 | class: classes.map((c) => `tok-problem-${c}`).join(' '), | 19 | ): TransactionSpec { |
19 | }).range(from, to)), true); | 20 | const rangeSet = RangeSet.of( |
21 | ranges.map(({ from, to, classes }) => | ||
22 | Decoration.mark({ | ||
23 | class: classes.map((c) => `tok-problem-${c}`).join(' '), | ||
24 | }).range(from, to), | ||
25 | ), | ||
26 | true, | ||
27 | ); | ||
20 | return setSemanticHighlightingInternal(rangeSet); | 28 | return setSemanticHighlightingInternal(rangeSet); |
21 | } | 29 | } |
22 | 30 | ||
23 | export { semanticHighlighting }; | 31 | export default semanticHighlighting; |