From 899746d51cf8bff86e4d4e52fd4e07dcd57597c6 Mon Sep 17 00:00:00 2001 From: micbou Date: Thu, 14 Jul 2016 02:39:33 +0200 Subject: [PATCH] Convert Vim buffers to bytes in ReplaceChunk --- python/ycm/vimsupport.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index c3a63915..17f32e68 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -803,8 +803,10 @@ def ReplaceChunk( start, end, replacement_text, line_delta, char_delta, replacement_lines = [ bytes( b'' ) ] replacement_lines_count = len( replacement_lines ) - end_existing_text = vim_buffer[ end_line ][ end_column : ] - start_existing_text = vim_buffer[ start_line ][ : start_column ] + # NOTE: Vim buffers are a list of byte objects on Python 2 but unicode + # objects on Python 3. + end_existing_text = ToBytes( vim_buffer[ end_line ] )[ end_column : ] + start_existing_text = ToBytes( vim_buffer[ start_line ] )[ : start_column ] new_char_delta = ( len( replacement_lines[ -1 ] ) - ( end_column - start_column ) )