Vim disables ibus IME -- is this a bug?

Posted by misha on Ask Ubuntu See other posts from Ask Ubuntu or by misha
Published on 2012-11-01T14:58:06Z Indexed on 2012/11/02 5:24 UTC
Read the original article Hit count: 605

Filed under:
|

I'm using ibus IME to input Japanese text into GVim. I have the following Vim script that I source when GVim starts up:

autocmd InsertLeave * :call bug#onInsertLeave()
function! bug#onInsertLeave()
  python << EOT
import vim
import ibus
bus = ibus.Bus()
ic = ibus.InputContext(bus, bus.current_input_contxt())
ic.disable()
print "bug#onInsertLeave(): exiting"
EOT
endfunction

The line that constructs the InputContext raises the exception:

dbus.exception.DBusException: org.freedesktop.DBus.Error.Failed: no focused input context

This happens under the following conditions:

  1. I enter insert mode
  2. I insert some Japanese text
  3. I exit insert mode

If I don't enter any Japanese text through the IME, then the exception is not raised.

I've also noticed that if I exit insert mode after entering some Japanese text while the IME is still enabled, then IME input is disabled (I can see the icon change in the taskbar). If I exit insert mode without entering any Japanese text, but while the IME is still enabled, then the IME stays enabled (the icon does not change). It seems like GVim is disabling the IME (or the IME is switching off) in some conditions. Could it be related to the exception?

My questions are:

  1. Is this a bug? If it is, then whose bug is it? Vim, Ibus, or something else?
  2. Are there any ways to work around the exception?

EDIT

My system info:

> misha@misha-lmd:~/git/iwait2013/lagos$ apt-cache policy ibus ibus:  
> Installed: 1.4.1-3ubuntu1   Candidate: 1.4.1-3ubuntu1   Version table:
> *** 1.4.1-3ubuntu1 0
>         500 http://jp.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
>         100 /var/lib/dpkg/status misha@misha-lmd:~/git/iwait2013/lagos$ apt-cache policy vim vim:  
> Installed: 2:7.3.429-2ubuntu2.1   Candidate: 2:7.3.429-2ubuntu2.1  
> Version table:  *** 2:7.3.429-2ubuntu2.1 0
>         500 http://jp.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
>         100 /var/lib/dpkg/status
>      2:7.3.429-2ubuntu2 0
>         500 http://jp.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages

Ubuntu 12.04, Fluxbox

© Ask Ubuntu or respective owner

Related posts about vim

Related posts about ibus