From b31f3dbc79c59b2667ba6434048ffbfd67a4e303 Mon Sep 17 00:00:00 2001 From: Boris Staletic Date: Tue, 17 Sep 2024 21:21:25 +0200 Subject: [PATCH] Make vimsupport.BuildRange construct a half-open range The rest of YCM is already dealing with half-open ranges and so does LSP. In fact, ycmd assumes this is a half-open range, so YCM had a bug. --- python/ycm/tests/command_test.py | 4 ++-- python/ycm/vimsupport.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/ycm/tests/command_test.py b/python/ycm/tests/command_test.py index 52ce467030..274697173b 100644 --- a/python/ycm/tests/command_test.py +++ b/python/ycm/tests/command_test.py @@ -99,7 +99,7 @@ def test_SendCommandRequest_BuildRange_NoVisualMarks( self, ycm, *args ): }, 'end': { 'line_num': 2, - 'column_num': 12 + 'column_num': 13 } } }, @@ -132,7 +132,7 @@ def test_SendCommandRequest_BuildRange_VisualMarks( self, ycm, *args ): }, 'end': { 'line_num': 2, - 'column_num': 9 + 'column_num': 10 } } }, diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index 2a29b1ede1..c7a192dcfd 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -1400,7 +1400,7 @@ def BuildRange( start_line, end_line ): # Vim returns the maximum 32-bit integer value when a whole line is # selected. Use the end of line instead. 'column_num': min( end[ 1 ], - len( vim.current.buffer[ end[ 0 ] - 1 ] ) ) + 1 + len( vim.current.buffer[ end[ 0 ] - 1 ] ) ) + 2 } } }