From 11a75d2429760bdc291bf82e385110f418b14610 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 19 May 2022 09:46:31 +0800 Subject: Fixes class PunctEditor --- src/PYPunctEditor.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PYPunctEditor.cc b/src/PYPunctEditor.cc index 54a32ef..adcb839 100644 --- a/src/PYPunctEditor.cc +++ b/src/PYPunctEditor.cc @@ -256,7 +256,7 @@ PunctEditor::cursorUp (void) void PunctEditor::cursorDown (void) { - if (G_LIKELY (m_lookup_table.cursorDown ())) { + if (G_LIKELY (m_lookup_table.size () && m_lookup_table.cursorDown ())) { m_selected_puncts[m_cursor - 1] = m_punct_candidates[m_lookup_table.cursorPos ()]; updateLookupTableFast (m_lookup_table, TRUE); updatePreeditText (); @@ -301,8 +301,8 @@ PunctEditor::moveCursorRight (void) it = std::find (m_punct_candidates.begin (), m_punct_candidates.end (), m_selected_puncts[m_cursor - 1]); - g_assert (it != m_punct_candidates.end ()); - m_lookup_table.setCursorPos (it - m_punct_candidates.begin ()); + if (it != m_punct_candidates.end ()) + m_lookup_table.setCursorPos (it - m_punct_candidates.begin ()); update(); return TRUE; @@ -314,7 +314,7 @@ PunctEditor::moveCursorToBegin (void) if (G_UNLIKELY (m_cursor == 0)) return FALSE; - g_assert (m_punct_mode == MODE_NORMAL); + g_assert (m_punct_mode == MODE_INIT || m_punct_mode == MODE_NORMAL); m_cursor = 0; m_punct_candidates.clear (); fillLookupTable (); -- cgit v1.2.1