Evgeny Podjachev avatar Evgeny Podjachev committed 4f749f8

Reverted previous revision as erroneous.
Code clean up.

Comments (0)

Files changed (1)

 
 	let index=str2nr(str)
 
-	autocmd! BufLeave <buffer>
-	autocmd! BufEnter <buffer>
-
 	let pos_in_yate = getpos(".") " save cursor position may halp later
 	exe ':wincmd p'
 	if !a:stationary
 		exe ':wincmd p'
 		call setpos('.', pos_in_yate)
 	endif
-
-	autocmd! BufLeave <buffer> OnBufLeave
-	autocmd! BufEnter <buffer> OnBufEnter
 endfun
 
 fun <SID>AutoCompleteString(str)
 	exe 'normal dd$'
 
 	if (!exists("s:tags_list")) || (!len(s:tags_list))
-		autocmd CursorMovedI <buffer> call <SID>OnCursorMovedI()
+		autocmd CursorMovedI <buffer> call <SID>OnCursorMoved(1)
 		return
 	endif
 
 		cal append(counter,str)
 	endfor
 
-	autocmd CursorMovedI <buffer> call <SID>OnCursorMovedI()
+	autocmd CursorMovedI <buffer> call <SID>OnCursorMoved(1)
 endfun
 
 fun! <SID>ShowHistory()
 	cal <SID>GenerateTagsList(getline('.'),1)
 endfun
 
-fun <SID>OnCursorMoved()
+fun <SID>OnCursorMoved(ins_mode)
 	if line('.') > 1
 		setlocal cul
 		setlocal noma
 		setlocal ma
 		
 		setlocal completefunc=CompleteYATEHistory
-	endif
-endfun
 
-fun <SID>OnCursorMovedI()
-	if line('.') > 1
-		setlocal cul
-		setlocal noma
-		
-		setlocal completefunc=''
-	else
-		setlocal nocul
-		setlocal ma
-
-		setlocal completefunc=CompleteYATEHistory
+		if a:ins_mode == 0
+			return
+		endif
 
 		if g:YATE_enable_real_time_search
 			let str=getline('.')
 
 			autocmd BufUnload <buffer> exe 'let s:yate_winnr=-1'
 			autocmd BufLeave <buffer> call <SID>OnBufLeave()
-			autocmd CursorMoved <buffer> call <SID>OnCursorMoved()
-			autocmd CursorMovedI <buffer> call <SID>OnCursorMovedI()
+			autocmd CursorMoved <buffer> call <SID>OnCursorMoved(0)
+			autocmd CursorMovedI <buffer> call <SID>OnCursorMoved(1)
 			autocmd VimResized <buffer> call <SID>PrintTagsList()
 			autocmd BufEnter <buffer> call <SID>OnBufEnter()
 		endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.