diff --git a/plugin/fcitx.py b/plugin/fcitx.py index 2b1c794..8842e7f 100644 --- a/plugin/fcitx.py +++ b/plugin/fcitx.py @@ -4,19 +4,22 @@ import os import vim import socket import struct + FCITX_STATUS = struct.pack('i', 0) FCITX_OPEN = struct.pack('i', 1 | (1 << 16)) FCITX_CLOSE = struct.pack('i', 1) INT_SIZE = struct.calcsize('i') fcitxsocketfile = vim.eval('s:fcitxsocketfile') + if fcitxsocketfile[0] == '@': # abstract socket fcitxsocketfile = '\x00' + fcitxsocketfile[1:] def fcitxtalk(command=None): sock = socket.socket(socket.AF_UNIX) + sock.settimeout(0.5) try: sock.connect(fcitxsocketfile) - except socket.error: + except (socket.error, socket.timeout): vim.command('echohl WarningMsg | echo "fcitx.vim: socket connection error" | echohl NONE') return try: @@ -29,7 +32,7 @@ def fcitxtalk(command=None): sock.send(FCITX_OPEN) else: raise ValueError('unknown fcitx command') - except struct.error: + except (struct.error, socket.timeout): # if there's a proxy of some kind, connect and send *will* succeed when # fcitx isn't there. vim.command('echohl WarningMsg | echo "fcitx.vim: socket error" | echohl NONE') diff --git a/plugin/fcitx.vim b/plugin/fcitx.vim index d654d8e..b0c7ab5 100644 --- a/plugin/fcitx.vim +++ b/plugin/fcitx.vim @@ -1,7 +1,7 @@ scriptencoding utf-8 " fcitx.vim remember fcitx's input state for each buffer " Author: lilydjwg -" Version: 1.2.4 +" Version: 1.2.5 " URL: http://www.vim.org/scripts/script.php?script_id=3764 " --------------------------------------------------------------------- " Load Once: