Workaround unexpected commitment of the node text when inpputting by IME

https://gist.github.com/somuro/9910657
and refactoring