Fixed multiple operation related to the workspace when using submodules

This commit is contained in:
Abdelilah El Aissaoui 2023-04-27 19:24:17 +02:00
parent 9da623f873
commit 4889a8072d
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
7 changed files with 26 additions and 28 deletions

View File

@ -65,11 +65,10 @@ fun Modifier.onDoubleClick(
): Modifier {
return this.pointerInput(Unit) {
coroutineScope {
forEachGesture {
awaitPointerEventScope {
awaitEachGesture {
// Detect first click without consuming it (other, independent handlers want it).
awaitFirstDown()
val firstUp = waitForUpOrCancellation() ?: return@awaitPointerEventScope
val firstUp = waitForUpOrCancellation() ?: return@awaitEachGesture
// Detect and consume the second click if it's received within the timeout.
val secondDown = withTimeoutOrNull(viewConfiguration.doubleTapTimeoutMillis) {
@ -80,9 +79,9 @@ fun Modifier.onDoubleClick(
change = awaitFirstDown()
} while (change.uptimeMillis < minUptime)
change
} ?: return@awaitPointerEventScope
} ?: return@awaitEachGesture
secondDown.consume()
val secondUp = waitForUpOrCancellation() ?: return@awaitPointerEventScope
val secondUp = waitForUpOrCancellation() ?: return@awaitEachGesture
secondUp.consume()
// Both clicks happened in time, fire the event.
@ -91,7 +90,6 @@ fun Modifier.onDoubleClick(
}
}
}
}
// TODO Try to restore hover that was shown with clickable modifier
@OptIn(ExperimentalComposeUiApi::class)

View File

@ -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()

View File

@ -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()

View File

@ -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)
}
}

View File

@ -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()
}

View File

@ -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(

View File

@ -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(