Commits

Evgeny Podjachev committed 6743634

Version 1.2.4: Fixed leaving of insert mode after leaving YATE buffer.

  • Participants
  • Parent commits 5112b4c

Comments (0)

Files changed (1)

File plugin/yate.vim

 " 				search string. Autocompletion using history also works by
 " 				<Ctrl-X><Ctrl-U>.
 "
-" Version:		1.2.3
+" Version:		1.2.4
 "
-" ChangeLog:	1.2.3:	Insert mode is default in YATE buffer.
+" ChangeLog:	1.2.4:	Fixed leaving of insert mode after leaving YATE buffer.
+" 				1.2.3:	Insert mode is default in YATE buffer.
 "				1.2.2:	Fixed cleaning of search string in some cases.
 "
 " 				1.2.1:	History menu (<Ctrl-H>) also works in normal mode.
 	cal <SID>GotoTag('e')
 endfun
 
+fun <SID>OnBufLeave()
+	if s:prev_mode != 'i'
+		exe 'stopinsert'
+	endif
+endfun
+
+fun <SID>OnBufEnter()
+	let s:prev_mode = mode()
+	exe 'startinsert'
+
+	call <SID>PrintTagsList()
+endfun
+
 fun! <SID>ToggleTagExplorerBuffer()
 	if !exists("s:yate_winnr") || s:yate_winnr==-1
 		exe "bo".g:YATE_window_height."sp YATE"
 		
 		setlocal buftype=nofile
 		setlocal noswapfile
-		setlocal insertmode
+
+		let s:prev_mode = mode()
+		exe 'startinsert'
 
 		if !exists("s:first_time")
 			let s:user_line=''
 			let s:first_time=1
 
 			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 VimResized <buffer> call <SID>PrintTagsList()
-			autocmd BufEnter <buffer> call <SID>PrintTagsList()
+			autocmd BufEnter <buffer> call <SID>OnBufEnter()
 		endif
 		
 		cal <SID>PrintTagsList()