Permalink
Browse files

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

  • Loading branch information...
1 parent dff5bc7 commit 59c3f97f8b6b93151603a1580675aba191b9169b @madevgeny madevgeny committed with Jul 14, 2012
Showing with 21 additions and 4 deletions.
  1. +21 −4 plugin/yate.vim
View
@@ -45,9 +45,10 @@
" 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.
@@ -356,6 +357,19 @@ fun <SID>GotoTagE()
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"
@@ -396,17 +410,20 @@ fun! <SID>ToggleTagExplorerBuffer()
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()

0 comments on commit 59c3f97

Please sign in to comment.