Skip to content

Commit

Permalink
fix: calculator cursor placement after evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhasDissa committed Dec 10, 2023
1 parent b3b04f2 commit cc448be
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/src/main/java/net/youapps/calcyou/data/EventHandler.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.youapps.calcyou.data

import android.content.Context
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.TextFieldValue

class EventHandler(
Expand Down Expand Up @@ -34,12 +35,14 @@ class EventHandler(

CalculatorEvent.Evaluate -> {
onUpdateHistory(currentText.text)
val newText = evaluator.evaluate(
tokenizer.getNormalizedExpression(
currentText.text
)
) ?: "Error"
TextFieldValue(
evaluator.evaluate(
tokenizer.getNormalizedExpression(
currentText.text
)
) ?: "Error"
newText,
selection = TextRange(newText.length)
)
}

Expand Down

0 comments on commit cc448be

Please sign in to comment.