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

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(