Upgrading to GitLab 11.10.0. Expect errors and see debian-infrastructure-announce@lists.debian.org for further information.

Commit 8a6dca08 authored by Mathieu Bridon's avatar Mathieu Bridon

Really automatically clear on errors

Commit 07c6055d introduced a fix for issue #22, so that we now
automatically clear the current input on a user mistake.

This commit just makes sure we actually always do that.

Specifically, we were missing the case where we had already reached the
maximum input length.

This commit also adds a unit test, to make sure we do not regress in the
future.
parent 5a48eb3c
......@@ -313,8 +313,11 @@ class Engine(IBus.Engine):
if self.clear_on_next_input:
self.clear_current_input()
self.current_input += append
self.current_radicals += self.cangjie.translateInputKeyToCangJie(append)
if len(self.current_input) < self.input_max_len:
self.current_input += append
self.current_radicals += self.cangjie.translateInputKeyToCangJie(append)
else:
self.play_error_bell()
elif drop is not None:
self.clear_on_next_input = False
......@@ -406,11 +409,7 @@ class EngineCangjie(Engine):
if self.lookuptable.get_number_of_candidates():
self.do_select_candidate(1)
if len(self.current_input) < self.input_max_len:
self.update_current_input(append=inputchar)
else:
self.play_error_bell()
self.update_current_input(append=inputchar)
return True
......
......@@ -201,3 +201,20 @@ class CangjieTestCase(unittest.TestCase):
self.assertEqual(len(self.engine._mock_auxiliary_text), 1)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
def test_autoclear_on_error_max_input(self):
# First make an error on purpose
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.space, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 5)
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
# Now go on inputting
self.engine.do_process_key_event(IBus.z, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 1)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment