@@ -20,6 +20,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
20
20
import { UnicodeHighlighterOptions , UnicodeHighlighterReason , UnicodeHighlighterReasonKind , UnicodeTextModelHighlighter } from 'vs/editor/common/modes/unicodeTextModelHighlighter' ;
21
21
import { IEditorWorkerService , IUnicodeHighlightsResult } from 'vs/editor/common/services/editorWorkerService' ;
22
22
import { IModeService } from 'vs/editor/common/services/modeService' ;
23
+ import { isModelDecorationVisible } from 'vs/editor/common/viewModel/viewModelDecorations' ;
23
24
import { HoverAnchor , HoverAnchorType , IEditorHover , IEditorHoverParticipant , IEditorHoverStatusBar , IHoverPart } from 'vs/editor/contrib/hover/hoverTypes' ;
24
25
import { MarkdownHover , renderMarkdownHovers } from 'vs/editor/contrib/hover/markdownHoverParticipant' ;
25
26
import { BannerController } from 'vs/editor/contrib/unicodeHighlighter/bannerController' ;
@@ -255,8 +256,21 @@ class DocumentUnicodeHighlighter extends Disposable {
255
256
if ( ! this . _decorationIds . has ( decorationId ) ) {
256
257
return null ;
257
258
}
258
- const range = this . _editor . getModel ( ) . getDecorationRange ( decorationId ) ! ;
259
- const text = this . _editor . getModel ( ) . getValueInRange ( range ) ;
259
+ const model = this . _editor . getModel ( ) ;
260
+ const range = model . getDecorationRange ( decorationId ) ! ;
261
+ if (
262
+ ! isModelDecorationVisible ( model , {
263
+ range : range ,
264
+ options : this . _options . includeComments
265
+ ? DECORATION
266
+ : DECORATION_HIDE_IN_COMMENTS ,
267
+ id : decorationId ,
268
+ ownerId : 0 ,
269
+ } )
270
+ ) {
271
+ return null ;
272
+ }
273
+ const text = model . getValueInRange ( range ) ;
260
274
return {
261
275
reason : computeReason ( text , this . _options ) ! ,
262
276
} ;
@@ -341,8 +355,21 @@ class ViewportUnicodeHighlighter extends Disposable {
341
355
if ( ! this . _decorationIds . has ( decorationId ) ) {
342
356
return null ;
343
357
}
344
- const range = this . _editor . getModel ( ) . getDecorationRange ( decorationId ) ! ;
345
- const text = this . _editor . getModel ( ) . getValueInRange ( range ) ;
358
+ const model = this . _editor . getModel ( ) ;
359
+ const range = model . getDecorationRange ( decorationId ) ! ;
360
+ const text = model . getValueInRange ( range ) ;
361
+ if (
362
+ ! isModelDecorationVisible ( model , {
363
+ range : range ,
364
+ options : this . _options . includeComments
365
+ ? DECORATION
366
+ : DECORATION_HIDE_IN_COMMENTS ,
367
+ id : decorationId ,
368
+ ownerId : 0 ,
369
+ } )
370
+ ) {
371
+ return null ;
372
+ }
346
373
return {
347
374
reason : computeReason ( text , this . _options ) ! ,
348
375
} ;
0 commit comments