From 4db6fb8d7f335219b2347be6c4d2a39966f4080d Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sat, 3 Aug 2013 18:42:16 -0700 Subject: [PATCH] Revert to old way of tracking insert mode change b:changedtick is incremented by the feedkeys() call which screws us up and there doesn't seem to be a way around it that's worth the hassle. --- autoload/youcompleteme.vim | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 096c6be9..cdf3c0ae 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -28,6 +28,8 @@ let s:omnifunc_mode = 0 let s:old_cursor_position = [] let s:cursor_moved = 0 +let s:moved_vertically_in_insert_mode = 0 +let s:previous_num_chars_on_current_line = -1 function! youcompleteme#Enable() " When vim is in diff mode, don't run @@ -357,9 +359,23 @@ endfunction function! s:BufferTextChangedSinceLastMoveInInsertMode() - let buffer_changed = b:changedtick != b:ycm_changedtick.insert_mode_move - let b:ycm_changedtick.insert_mode_move = b:changedtick - return buffer_changed + if s:moved_vertically_in_insert_mode + let s:previous_num_chars_on_current_line = -1 + return 0 + endif + + let num_chars_in_current_cursor_line = strlen( getline('.') ) + + if s:previous_num_chars_on_current_line == -1 + let s:previous_num_chars_on_current_line = num_chars_in_current_cursor_line + return 0 + endif + + let changed_text_on_current_line = num_chars_in_current_cursor_line != + \ s:previous_num_chars_on_current_line + let s:previous_num_chars_on_current_line = num_chars_in_current_cursor_line + + return changed_text_on_current_line endfunction