fix phantom space after double quotes (#842)

and add a bunch of related tests

---------

Co-authored-by: Helium314 <helium314@mailbox.org>
This commit is contained in:
codokie 2024-06-24 19:32:16 +03:00 committed by GitHub
parent 4a9dc6bff6
commit fc0d27459f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 50 additions and 8 deletions

View file

@ -545,8 +545,50 @@ class InputLogicTest {
assertEquals("hello ", text)
}
@Test fun `no weird space inside multi-"`() {
reset()
chainInput("\"\"\"")
assertEquals("\"\"\"", text)
reset()
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
chainInput("\"\"\"")
assertEquals("\"\"\"", text)
}
@Test fun `autospace still happens after "`() {
reset()
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
chainInput("\"hello\"you")
assertEquals("\"hello\" you", text)
}
@Test fun `autospace still happens after " if next word is in quotes`() {
reset()
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
chainInput("\"hello\"\"you\"")
assertEquals("\"hello\" \"you\"", text)
}
@Test fun `autospace propagates over "`() {
reset()
input('"')
pickSuggestion("hello")
assertEquals(spaceState, SpaceState.PHANTOM) // picking a suggestion sets phantom space state
chainInput("\"you")
assertEquals("\"hello\" you", text)
}
@Test fun `autospace still happens after " if nex word is in " and after comma`() {
reset()
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
chainInput("\"hello\",\"you\"")
assertEquals("\"hello\", \"you\"", text)
}
@Test fun `autospace in json editor`() {
reset()
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
chainInput("{\"label\":\"")
assertEquals("{\"label\": \"", text)
input('c')