From 2a8794d62d517017d00ae044c31a0db323cc58b7 Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Sat, 4 Dec 2021 06:53:13 +0100 Subject: [PATCH] Disabled commit with ctrl+enter if commtis conditions are not met --- src/main/kotlin/app/ui/UncommitedChanges.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/ui/UncommitedChanges.kt b/src/main/kotlin/app/ui/UncommitedChanges.kt index 623599f..239255f 100644 --- a/src/main/kotlin/app/ui/UncommitedChanges.kt +++ b/src/main/kotlin/app/ui/UncommitedChanges.kt @@ -66,6 +66,7 @@ fun UncommitedChanges( onStagedDiffEntrySelected(null) commitMessage = "" } + val canCommit = commitMessage.isNotEmpty() && staged.isNotEmpty() Column { AnimatedVisibility( @@ -136,7 +137,7 @@ fun UncommitedChanges( .fillMaxWidth() .weight(weight = 1f, fill = true) .onPreviewKeyEvent { - if (it.isCtrlPressed && it.key == Key.Enter) { + if (it.isCtrlPressed && it.key == Key.Enter && canCommit) { doCommit() true } @@ -157,7 +158,7 @@ fun UncommitedChanges( onClick = { doCommit() }, - enabled = commitMessage.isNotEmpty() && staged.isNotEmpty(), + enabled = canCommit, shape = RectangleShape, ) { Text(