Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/src/main/java/helium314/keyboard/latin/WordComposer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ class WordComposer {
* @param codePoints the code points to set as the composing word.
* @param coordinates the x, y coordinates of the key in the CoordinateUtils format
*/
fun setComposingWord(codePoints: IntArray, coordinates: IntArray) {
/** [isResumed]: the word comes from existing text (no auto-correction, the typed word is not added to the suggestions) */
fun setComposingWord(codePoints: IntArray, coordinates: IntArray, isResumed: Boolean = true) {
reset()

for (i in codePoints.indices) {
Expand All @@ -317,7 +318,7 @@ class WordComposer {
applyProcessedEvent(processedEvent)
}

mIsResumed = true
mIsResumed = isResumed
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1985,9 +1985,13 @@ class InputLogic(
return false
}
val codePoints = StringUtils.toCodePointArray(replacement)
// keys are found by their lower case letter, upper case letters would have no position
val coordinates = mLatinIME.getCoordinatesForCurrentKeyboard(codePoints.map { Character.toLowerCase(it) }.toIntArray())
// still the typed word, not one from existing text: suggestions and auto-correction as before the shift
val wasResumed = mWordComposer.isResumed()
mConnection.beginBatchEdit()
try {
mWordComposer.setComposingWord(codePoints, mLatinIME.getCoordinatesForCurrentKeyboard(codePoints))
mWordComposer.setComposingWord(codePoints, coordinates, isResumed = wasResumed)
setComposingTextInternal(replacement, 1)
} finally {
mConnection.endBatchEdit()
Expand Down
11 changes: 11 additions & 0 deletions app/src/test/java/helium314/keyboard/latin/InputLogicTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,17 @@ class InputLogicTest {
assertEquals("hello ", text)
}

@Test fun `shift on a typed word keeps it a typed word`() {
reset()
latinIME.prefs().edit { putBoolean(Settings.PREF_SHIFT_RECAPITALIZES_WORD, true) }
chainInput("radumfang")
shiftTap()
assertEquals("Radumfang", composingText)
// not treated like a word from existing text, which would change suggestions and auto-correction
assertEquals(false, composer.isResumed())
assertEquals("Radumfang", composer.getTypedWord())
}

@Test fun `caps lock from shift on a word ends with the word`() {
reset()
latinIME.prefs().edit { putBoolean(Settings.PREF_SHIFT_RECAPITALIZES_WORD, true) }
Expand Down
Loading