diff --git a/java/src/org/futo/inputmethod/latin/inputlogic/InputLogic.java b/java/src/org/futo/inputmethod/latin/inputlogic/InputLogic.java
index 98bb323c2bb33e8c530057ff0391fe6920504c9b..ebf85d5656296a9eb1e0cc7fba750c2fed3665c1 100644
--- a/java/src/org/futo/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/org/futo/inputmethod/latin/inputlogic/InputLogic.java
@@ -1115,6 +1115,9 @@ public final class InputLogic {
                 }
             }
 
+            final boolean fieldEmptyBeforeText =
+                    (mConnection.getCodePointBeforeCursor() == Constants.NOT_A_CODE);
+
             sendKeyCodePoint(settingsValues, codePoint);
 
             boolean codeShouldBeFollowedBySpace = false;
@@ -1138,8 +1141,7 @@ public final class InputLogic {
             // Do not automatically insert a space if there is no text preceding the cursor
             // (e.g. if we are typing "!g", do not insert space after exclamation mark,
             // and if we are typing ":)", do not insert space after colon)
-            codeShouldBeFollowedBySpace = codeShouldBeFollowedBySpace
-                    && (mConnection.getCodePointBeforeCursor() != Constants.NOT_A_CODE);
+            codeShouldBeFollowedBySpace = codeShouldBeFollowedBySpace && !fieldEmptyBeforeText;
 
             if(autoInsertSpaces && codeShouldBeFollowedBySpace) {
                 insertOrSetPhantomSpace(settingsValues);