瀏覽代碼

Adds a workaround for input system race conditions (double characters)

devmil 4 年之前
父節點
當前提交
9a6369a99c
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      lib/frontend/input_behavior_default.dart

+ 7 - 0
lib/frontend/input_behavior_default.dart

@@ -51,6 +51,13 @@ class InputBehaviorDefault extends InputBehavior {
       terminal.updateComposingString('');
     }
 
+    //this is a hack to bypass some race condition in the input system
+    //we just take the last rune if there are more than one as it sometimes
+    //happens that the last value is still part of the new value
+    if(inputText.runes.length > 1) {
+      inputText = String.fromCharCode(inputText.runes.last);
+    }
+
     terminal.raiseOnInput(inputText);
 
     if (value == TextEditingValue.empty || inputText == '') {