diff options
author | Peng Wu <alexepico@gmail.com> | 2012-08-03 11:11:27 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-08-03 11:11:27 +0800 |
commit | b30095a04e11dca7d377d6938f27d1a04a56e128 (patch) | |
tree | f4a7f59552cda0cd050a1b11d5932f76d636f0fb /src/PYPPhoneticEditor.cc | |
parent | b4e468ed1cf74b3050a04d5cdf8422acc8118b23 (diff) | |
download | ibus-libpinyin-b30095a04e11dca7d377d6938f27d1a04a56e128.tar.gz ibus-libpinyin-b30095a04e11dca7d377d6938f27d1a04a56e128.tar.xz ibus-libpinyin-b30095a04e11dca7d377d6938f27d1a04a56e128.zip |
fixes getCursorLeftByWord
Diffstat (limited to 'src/PYPPhoneticEditor.cc')
-rw-r--r-- | src/PYPPhoneticEditor.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc index b89db91..1cc3306 100644 --- a/src/PYPPhoneticEditor.cc +++ b/src/PYPPhoneticEditor.cc @@ -483,9 +483,17 @@ LibPinyinPhoneticEditor::getCursorLeftByWord (void) } else { PinyinKeyPosVector & pinyin_poses = m_instance->m_pinyin_key_rests; guint pinyin_cursor = getPinyinCursor (); - PinyinKeyPos *pos = &g_array_index - (pinyin_poses, PinyinKeyPos, pinyin_cursor); - cursor = pos->m_raw_begin; + + PinyinKeyPos *pos = NULL; + + if (pinyin_cursor < pinyin_poses->len) { + pos = &g_array_index + (pinyin_poses, PinyinKeyPos, pinyin_cursor); + cursor = pos->m_raw_begin; + } else { + /* at the end of pinyin string. */ + cursor = m_cursor; + } /* cursor at the begin of one pinyin */ g_return_val_if_fail (pinyin_cursor > 0, 0); |