From 836cd2a7f8a7acb668635133c43700cee8035afb Mon Sep 17 00:00:00 2001 From: Yauheni Slizh Date: Mon, 2 Feb 2026 21:06:42 +0100 Subject: [PATCH 1/4] Fix timer issue --- .../kiolk/typingplugin/ui/TypingDialog.kt | 21 +++++++++++++++---- .../kiolk/typingplugin/ui/TypingDialogTest.kt | 11 ++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/github/kiolk/typingplugin/ui/TypingDialog.kt b/src/main/kotlin/com/github/kiolk/typingplugin/ui/TypingDialog.kt index 5256044..b97fd93 100644 --- a/src/main/kotlin/com/github/kiolk/typingplugin/ui/TypingDialog.kt +++ b/src/main/kotlin/com/github/kiolk/typingplugin/ui/TypingDialog.kt @@ -223,7 +223,7 @@ class TypingDialog(private val project: Project, private val sourceCode: String) private fun showStatistics() { val endTime = System.currentTimeMillis() - val totalTimeSeconds = (endTime - startTime) / 1000.0 + val totalTimeSeconds = if (startTime != 0L) (endTime - startTime) / 1000.0 else 0.0 val totalTimeMinutes = totalTimeSeconds / 60.0 val totalChars = sourceCode.length val wpm = if (totalTimeMinutes > 0) (totalChars / 5.0) / totalTimeMinutes else 0.0 @@ -234,9 +234,22 @@ class TypingDialog(private val project: Project, private val sourceCode: String) 0.0 } - val statsMessage = "Typing Finished!\n\nTime: ${"%.1f".format( - totalTimeSeconds, - )}s\nWPM: ${"%.1f".format(wpm)}\nAccuracy: ${"%.1f".format(accuracy)}%\nErrors: $errorCount" + val timeFormatted = formatTime(totalTimeSeconds) + + val statsMessage = "Typing Finished!\n\nTime: $timeFormatted\nWPM: ${"%.1f".format( + wpm, + )}\nAccuracy: ${"%.1f".format(accuracy)}%\nErrors: $errorCount" Messages.showInfoMessage(project, statsMessage, "Session Summary") } + + companion object { + fun formatTime(totalTimeSeconds: Double): String { + if (totalTimeSeconds >= 60) { + val minutes = totalTimeSeconds.toInt() / 60 + val seconds = totalTimeSeconds % 60 + return "${minutes}m ${"%.1f".format(seconds)}s" + } + return "${"%.1f".format(totalTimeSeconds)}s" + } + } } diff --git a/src/test/kotlin/com/github/kiolk/typingplugin/ui/TypingDialogTest.kt b/src/test/kotlin/com/github/kiolk/typingplugin/ui/TypingDialogTest.kt index 3ff2f3d..fa21687 100644 --- a/src/test/kotlin/com/github/kiolk/typingplugin/ui/TypingDialogTest.kt +++ b/src/test/kotlin/com/github/kiolk/typingplugin/ui/TypingDialogTest.kt @@ -78,6 +78,17 @@ class TypingDialogTest : BasePlatformTestCase() { assertEquals(Color.GREEN, StyleConstants.getForeground(attrsSpace)) } + @Test + fun testFormatTime() { + assertEquals("0.0s", TypingDialog.formatTime(0.0)) + assertEquals("30.0s", TypingDialog.formatTime(30.0)) + assertEquals("59.9s", TypingDialog.formatTime(59.9)) + assertEquals("1m 0.0s", TypingDialog.formatTime(60.0)) + assertEquals("1m 5.4s", TypingDialog.formatTime(65.4)) + assertEquals("2m 5.4s", TypingDialog.formatTime(125.4)) + assertEquals("10m 0.0s", TypingDialog.formatTime(600.0)) + } + private fun simulateType(char: Char) { val keyEvent = KeyEvent(textPane, KeyEvent.KEY_TYPED, System.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, char) textPane.keyListeners.forEach { it.keyTyped(keyEvent) } From 5dbad4ac53129c7708ac3ab6c763ce16ec30fb25 Mon Sep 17 00:00:00 2001 From: Yauheni Slizh Date: Mon, 2 Feb 2026 21:12:35 +0100 Subject: [PATCH 2/4] Bump versiont with description of changes --- build.gradle.kts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a858d4d..44b9bd4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { id("org.jlleitschuh.gradle.ktlint") version "12.1.2" } -version = "1.0.4" +version = "1.0.5" group = "com.github.kiolk.typingplugin" @@ -35,15 +35,9 @@ dependencies { intellijPlatform { pluginConfiguration { name = "Typing Training" - description = - """ - Improved stability and usability. - - Added ability to drag typing dialog to any position on the screen. - - Improved stability. - """.trimIndent() changeNotes = """ - - Added ability to drag typing dialog to any position on the screen. + - Fixed incorrect representation of the time on the final statistic dialog. - Improved stability. """.trimIndent() ideaVersion { From 0a8f0816343cc946b2c5e06ee184733086370654 Mon Sep 17 00:00:00 2001 From: Yauheni Slizh <30602586+Kiolk@users.noreply.github.com> Date: Mon, 2 Feb 2026 21:14:50 +0100 Subject: [PATCH 3/4] Fix time representation in statistics dialog and bump version to 1.0.5 - Formatted time as 'Mm Ss' when duration exceeds 60 seconds - Added unit tests for time formatting - Updated changeNotes in build.gradle.kts - Bumped version to 1.0.5 Closes #2 --- build.gradle.kts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 44b9bd4..5cc0d34 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,6 +35,12 @@ dependencies { intellijPlatform { pluginConfiguration { name = "Typing Training" + description = + """ + Improved stability and usability. + - Added ability to drag typing dialog to any position on the screen. + - Improved stability. + """.trimIndent() changeNotes = """ - Fixed incorrect representation of the time on the final statistic dialog. From 78c4e5377cef91c6b7b59c412566abbcd567e44a Mon Sep 17 00:00:00 2001 From: Yauheni Slizh Date: Mon, 2 Feb 2026 21:20:43 +0100 Subject: [PATCH 4/4] Remove description from plugin properties --- build.gradle.kts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5cc0d34..44b9bd4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,12 +35,6 @@ dependencies { intellijPlatform { pluginConfiguration { name = "Typing Training" - description = - """ - Improved stability and usability. - - Added ability to drag typing dialog to any position on the screen. - - Improved stability. - """.trimIndent() changeNotes = """ - Fixed incorrect representation of the time on the final statistic dialog.