Fix a crash where revertSwap would be wrongly called

This would crash the program when inputting a punctuation
symbol that should not swap with a weak space through the
suggestion strip, then press backspace.
Those include all two-part punctuation symbols in French for
example, as well as magic space strippers like the dash in
English. For English all suggestion strips symbols happen to
be magic space swappers so this would not happen in English
by default.
Also fix a typo.

Change-Id: Ia40678c264e978509b5786290a75a3c57181648e
This commit is contained in:
Jean Chalard 2012-01-12 11:09:10 +09:00
parent 8c111043b8
commit 9de5cfc67a

View file

@ -1202,7 +1202,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// swap it, and override the space state with SPACESTATE_SWAP_PUNCTUATION. // swap it, and override the space state with SPACESTATE_SWAP_PUNCTUATION.
// To swap it, we fool handleSeparator to think the previous space state was a // To swap it, we fool handleSeparator to think the previous space state was a
// magic space. // magic space.
if (Keyboard.CODE_SPACE == toLeft && mSpaceState == SPACE_STATE_WEAK) { if (Keyboard.CODE_SPACE == toLeft && mSpaceState == SPACE_STATE_WEAK
&& mSettingsValues.isMagicSpaceSwapper(code))) {
mSpaceState = SPACE_STATE_MAGIC; mSpaceState = SPACE_STATE_MAGIC;
shouldRegisterSwapPunctuation = true; shouldRegisterSwapPunctuation = true;
} else { } else {
@ -2180,7 +2181,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// enter surrogate pairs this code will have been removed. // enter surrogate pairs this code will have been removed.
if (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1)) { if (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1)) {
// We should not have come here if the text before the cursor is not a space. // We should not have come here if the text before the cursor is not a space.
throw new RuntimeException("Tried to revert a swap of punctiation but we didn't " throw new RuntimeException("Tried to revert a swap of punctuation but we didn't "
+ "find a space just before the cursor."); + "find a space just before the cursor.");
} }
ic.beginBatchEdit(); ic.beginBatchEdit();