diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/extensions/ModifierExtensions.kt b/src/main/kotlin/com/jetpackduba/gitnuro/extensions/ModifierExtensions.kt index 118e514..177b1f6 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/extensions/ModifierExtensions.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/extensions/ModifierExtensions.kt @@ -65,29 +65,27 @@ fun Modifier.onDoubleClick( ): Modifier { return this.pointerInput(Unit) { coroutineScope { - forEachGesture { - awaitPointerEventScope { - // Detect first click without consuming it (other, independent handlers want it). - awaitFirstDown() - val firstUp = waitForUpOrCancellation() ?: return@awaitPointerEventScope + awaitEachGesture { + // Detect first click without consuming it (other, independent handlers want it). + awaitFirstDown() + val firstUp = waitForUpOrCancellation() ?: return@awaitEachGesture - // Detect and consume the second click if it's received within the timeout. - val secondDown = withTimeoutOrNull(viewConfiguration.doubleTapTimeoutMillis) { - val minUptime = firstUp.uptimeMillis + viewConfiguration.doubleTapMinTimeMillis - var change: PointerInputChange - // The second tap doesn't count if it happens before DoubleTapMinTime of the first tap - do { - change = awaitFirstDown() - } while (change.uptimeMillis < minUptime) - change - } ?: return@awaitPointerEventScope - secondDown.consume() - val secondUp = waitForUpOrCancellation() ?: return@awaitPointerEventScope - secondUp.consume() + // Detect and consume the second click if it's received within the timeout. + val secondDown = withTimeoutOrNull(viewConfiguration.doubleTapTimeoutMillis) { + val minUptime = firstUp.uptimeMillis + viewConfiguration.doubleTapMinTimeMillis + var change: PointerInputChange + // The second tap doesn't count if it happens before DoubleTapMinTime of the first tap + do { + change = awaitFirstDown() + } while (change.uptimeMillis < minUptime) + change + } ?: return@awaitEachGesture + secondDown.consume() + val secondUp = waitForUpOrCancellation() ?: return@awaitEachGesture + secondUp.consume() - // Both clicks happened in time, fire the event. - onDoubleClick() - } + // Both clicks happened in time, fire the event. + onDoubleClick() } } } diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/DiscardUnstagedHunkLineUseCase.kt b/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/DiscardUnstagedHunkLineUseCase.kt index 861de26..a52da57 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/DiscardUnstagedHunkLineUseCase.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/DiscardUnstagedHunkLineUseCase.kt @@ -20,7 +20,7 @@ class DiscardUnstagedHunkLineUseCase @Inject constructor( val repository = git.repository try { - val file = File(repository.directory.parent, diffEntry.oldPath) + val file = File(repository.workTree, diffEntry.oldPath) val content = file.readText() val textLines = getLinesFromTextUseCase(content, content.lineDelimiter).toMutableList() diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/ResetHunkUseCase.kt b/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/ResetHunkUseCase.kt index 69ff015..c03d90e 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/ResetHunkUseCase.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/ResetHunkUseCase.kt @@ -18,7 +18,7 @@ class ResetHunkUseCase @Inject constructor( val repository = git.repository try { - val file = File(repository.directory.parent, diffEntry.oldPath) + val file = File(repository.workTree, diffEntry.oldPath) val content = file.readText() val textLines = getLinesFromTextUseCase(content, content.lineDelimiter).toMutableList() diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/MenuViewModel.kt b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/MenuViewModel.kt index dc3dc1a..91ffef0 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/MenuViewModel.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/MenuViewModel.kt @@ -70,6 +70,6 @@ class MenuViewModel @Inject constructor( fun openTerminal() = tabState.runOperation( refreshType = RefreshType.NONE ) { git -> - openRepositoryInTerminalUseCase(git.repository.directory.parent) + openRepositoryInTerminalUseCase(git.repository.workTree.absolutePath) } } \ No newline at end of file diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/StatusViewModel.kt b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/StatusViewModel.kt index 7afe995..dd329d9 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/StatusViewModel.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/StatusViewModel.kt @@ -351,7 +351,7 @@ class StatusViewModel @Inject constructor( ) { git -> val path = statusEntry.filePath - val fileToDelete = File(git.repository.directory.parent, path) + val fileToDelete = File(git.repository.workTree, path) fileToDelete.delete() } diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/TabViewModel.kt b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/TabViewModel.kt index 6c544e2..fb8aceb 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/TabViewModel.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/TabViewModel.kt @@ -285,7 +285,7 @@ class TabViewModel @Inject constructor( } } fileChangesWatcher.watchDirectoryPath( - pathStr = git.repository.directory.parent, + pathStr = git.repository.workTree.absolutePath, ignoredDirsPath = ignored, ) } @@ -456,7 +456,7 @@ class TabViewModel @Inject constructor( showError = true, refreshType = RefreshType.NONE, ) { git -> - Desktop.getDesktop().open(git.repository.directory.parentFile) + Desktop.getDesktop().open(git.repository.workTree) } fun cancelRebaseInteractive() = tabState.safeProcessing( diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/sidepanel/SubmodulesViewModel.kt b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/sidepanel/SubmodulesViewModel.kt index af20237..65464df 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/sidepanel/SubmodulesViewModel.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/sidepanel/SubmodulesViewModel.kt @@ -65,7 +65,7 @@ class SubmodulesViewModel @AssistedInject constructor( } fun onOpenSubmoduleInTab(path: String) = tabState.runOperation(refreshType = RefreshType.NONE) { git -> - tabsManager.addNewTabFromPath("${git.repository.directory.parent}/$path", true) + tabsManager.addNewTabFromPath("${git.repository.workTree}/$path", true) } fun onDeinitializeSubmodule(path: String) = tabState.safeProcessing(