Browse Source

Fix errors when adding inlay hints

Recent vims validate that you can't supply end_lnum/end_col with a text
property, so don't supply them.
Ben Jackson 2 years ago
parent
commit
728b47728c
2 changed files with 5 additions and 5 deletions
  1. 0 3
      python/ycm/inlay_hints.py
  2. 5 2
      python/ycm/text_properties.py

+ 0 - 3
python/ycm/inlay_hints.py

@@ -165,7 +165,6 @@ class InlayHints:
                             'YCM_INLAY_PADDING',
                             {
                               'start': inlay_hint[ 'position' ],
-                              'end': inlay_hint[ 'position' ],
                             },
                             {
                               'text': ' '
@@ -176,7 +175,6 @@ class InlayHints:
                           prop_type,
                           {
                             'start': inlay_hint[ 'position' ],
-                            'end': inlay_hint[ 'position' ],
                           },
                           {
                             'text': inlay_hint[ 'label' ]
@@ -188,7 +186,6 @@ class InlayHints:
                             'YCM_INLAY_PADDING',
                             {
                               'start': inlay_hint[ 'position' ],
-                              'end': inlay_hint[ 'position' ],
                             },
                             {
                               'text': ' '

+ 5 - 2
python/ycm/text_properties.py

@@ -53,8 +53,6 @@ def AddTextProperty( bufnr,
                      range,
                      extra_args: dict = None ):
   props = {
-    'end_lnum': range[ 'end' ][ 'line_num' ],
-    'end_col': range[ 'end' ][ 'column_num' ],
     'bufnr': bufnr,
     'type': prop_type
   }
@@ -62,6 +60,11 @@ def AddTextProperty( bufnr,
     props[ 'id' ] = prop_id
   if extra_args:
     props.update( extra_args )
+  if 'end' in range:
+    props.update( {
+      'end_lnum': range[ 'end' ][ 'line_num' ],
+      'end_col':  range[ 'end' ][ 'column_num' ],
+    } )
   return vim.eval( f"prop_add( { range[ 'start' ][ 'line_num' ] },"
                    f"          { range[ 'start' ][ 'column_num' ] },"
                    f"          { json.dumps( props ) } )" )