@@ -210,16 +210,26 @@ static NSUInteger textInputModifiers;
210210 * In IME the Enter key is used to terminate a composition sequence.
211211 * When there are multiple choices of input text available, and the
212212 * user's selected choice is not the default, it may be necessary to
213- * hit the Enter key multiple times before the text is accepted and
214- * rendered (See ticket 39de9677aa]). So when sending an Enter key
215- * during composition, we continue sending Enter keys until the
216- * inputText method has cleared the processingCompose flag.
213+ * hit the Enter key twice before the text is accepted and rendered
214+ * (See ticket [39de9677aa]). So when sending an Enter key during
215+ * composition, we continue sending Enter keys until the inputText
216+ * method has cleared the processingCompose flag. However, ticket
217+ * [0fb2a9cd132] reported that it is possible for the processingCompose
218+ * flag to not get set in spite of repeatedly sending Enter keys,
219+ * leading to a hang. To avoid this we exit the loop after 10
220+ * attempts.
217221 */
218222
219223 if (processingCompose && [theEvent keyCode ] == 36 ) {
220224 [nsEvArray addObject : theEvent ];
221- while (processingCompose ) {
222- [[w contentView ] interpretKeyEvents : nsEvArray ];
225+ int counter = 0 ;
226+ TKContentView * view = [w contentView ];
227+ while (processingCompose ) {
228+ [view interpretKeyEvents : nsEvArray ];
229+ if (++ counter > 10 ) {
230+ [view cancelComposingText ];
231+ break ;
232+ }
223233 }
224234 [nsEvArray removeObject : theEvent ];
225235 } else {
0 commit comments