fix missing auto-space with url detection

caused by bug in nonWordCodePointAndNoSpaceBeforeCursor
fixes #229
This commit is contained in:
Helium314 2023-10-21 08:29:47 +02:00
parent d47386c745
commit 9975a7d8f6
2 changed files with 16 additions and 2 deletions

View file

@ -34,9 +34,9 @@ fun nonWordCodePointAndNoSpaceBeforeCursor(s: CharSequence, spacingAndPunctuatio
space = true space = true
if (!nonWordCodePoint && !spacingAndPunctuations.isWordCodePoint(it)) if (!nonWordCodePoint && !spacingAndPunctuations.isWordCodePoint(it))
nonWordCodePoint = true nonWordCodePoint = true
space && nonWordCodePoint space && nonWordCodePoint // stop if both are found
} }
return space && nonWordCodePoint return nonWordCodePoint && !space // return true if an non-word codepoint and no space was found
} }
fun hasLetterBeforeLastSpaceBeforeCursor(s: CharSequence): Boolean { fun hasLetterBeforeLastSpaceBeforeCursor(s: CharSequence): Boolean {

View file

@ -463,6 +463,20 @@ class InputLogicTest {
assertEquals("b", composingText) assertEquals("b", composingText)
} }
@Test fun `autospace works in URL field when input isn't URL, also for multiple suggestions`() {
reset()
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
pickSuggestion("this")
pickSuggestion("is")
assertEquals("this is", text)
pickSuggestion("not")
assertEquals("this is not", text)
input('c')
assertEquals("this is not c", text)
assertEquals("c", composingText)
}
@Test fun `emoji is added to dictionary`() { @Test fun `emoji is added to dictionary`() {
// check both text and codepoint input // check both text and codepoint input
reset() reset()