Skip to content

Commit f09c2f6

Browse files
authored
Merge pull request #4164 from ycm-core/fix-custom-props-semantic-highlighting
Fix custom text properties for semantic highlighting
2 parents 142a559 + 1ca1512 commit f09c2f6

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

python/ycm/semantic_highlighting.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
from ycm import text_properties as tp
2323
from ycm import scrolling_range as sr
2424

25+
import vim
26+
2527

2628
HIGHLIGHT_GROUP = {
2729
'namespace': 'Type',
@@ -107,16 +109,21 @@ def _Draw( self ):
107109
self._prop_id = NextPropID()
108110

109111
for token in tokens:
110-
if token[ 'type' ] not in HIGHLIGHT_GROUP:
111-
if token[ 'type' ] not in REPORTED_MISSING_TYPES:
112-
REPORTED_MISSING_TYPES.add( token[ 'type' ] )
113-
vimsupport.PostVimMessage(
114-
f"Missing property type for { token[ 'type' ] }" )
115-
continue
116112
prop_type = f"YCM_HL_{ token[ 'type' ] }"
117-
118113
rng = token[ 'range' ]
119114
self.GrowRangeIfNeeded( rng )
120-
tp.AddTextProperty( self._bufnr, self._prop_id, prop_type, rng )
115+
116+
try:
117+
tp.AddTextProperty( self._bufnr, self._prop_id, prop_type, rng )
118+
except vim.error as e:
119+
if 'E971:' in str( e ): # Text property doesn't exist
120+
if token[ 'type' ] not in REPORTED_MISSING_TYPES:
121+
REPORTED_MISSING_TYPES.add( token[ 'type' ] )
122+
vimsupport.PostVimMessage(
123+
f"Token type { token[ 'type' ] } not supported. "
124+
f"Define property type { prop_type }. "
125+
f"See :help youcompleteme-customising-highlight-groups" )
126+
else:
127+
raise e
121128

122129
tp.ClearTextProperties( self._bufnr, prop_id = prev_prop_id )

0 commit comments

Comments
 (0)