fix issue that could result in autospace being added before period

This commit is contained in:
Helium314 2025-03-26 18:29:57 +01:00
parent b600431af9
commit c0b14635fd
2 changed files with 4 additions and 7 deletions

View file

@ -949,7 +949,9 @@ public final class InputLogic {
// TODO: remove isWordConnector() and use isUsuallyFollowedBySpace() instead.
// See onStartBatchInput() to see how to do it.
if (SpaceState.PHANTOM == inputTransaction.getMSpaceState()
&& !settingsValues.isWordConnector(codePoint)) {
&& !settingsValues.isWordConnector(codePoint)
&& !settingsValues.isUsuallyFollowedBySpace(codePoint) // only relevant in rare cases
) {
if (isComposingWord) {
// Sanity check
throw new RuntimeException("Should not be composing here");

View file

@ -203,13 +203,7 @@ class InputLogicTest {
assertEquals("example.net", composingText)
}
// fails because
// period is not handled with handleSeparatorEvent in this case
// pickSuggestion sets phantom space state
// insertAutomaticSpaceIfOptionsAndTextAllow allows the space
// todo: fix it either in some of those functions, or by finally improving URL detection in a reasonable (and performant) way
@Test fun noAutospaceInUrlFieldWhenPickingSuggestion() {
if (BuildConfig.BUILD_TYPE == "runTests") return
reset()
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
chainInput("exam")
@ -262,6 +256,7 @@ class InputLogicTest {
reset()
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
latinIME.prefs().edit { putBoolean(Settings.PREF_SHIFT_REMOVES_AUTOSPACE, true) }
input("bla")
input('.')
functionalKeyPress(KeyCode.SHIFT) // should remove the phantom space (in addition to normal effect)