Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package com.intellij.vcs.log.impl
import com.intellij.openapi.application.EdtImmediate
import com.intellij.openapi.application.UiImmediate
import com.intellij.openapi.components.service
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.VirtualFile
Expand All @@ -22,7 +21,6 @@ import com.intellij.vcs.log.impl.VcsLogNavigationUtil.showCommit
import com.intellij.vcs.log.impl.VcsLogNavigationUtil.showCommitSync
import com.intellij.vcs.log.ui.MainVcsLogUi
import com.intellij.vcs.log.ui.VcsLogUiEx
import com.intellij.vcs.log.ui.editor.VcsLogVirtualFileSystem
import com.intellij.vcs.log.util.VcsLogUtil
import com.intellij.vcs.log.visible.filters.VcsLogFilterObject
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -62,9 +60,7 @@ internal class IdeVcsLogManager(
mainUiHolderState.collect { holder ->
val showLogInEditorWindow = service<VcsLogApplicationSettings>()[CommonUiProperties.SHOW_IN_EDITOR]
val ui = if (showLogInEditorWindow) {
val file = VcsLogVirtualFileSystem.Holder.getInstance().
createVcsLogFile(project, "", null)
val editor = FileEditorManager.getInstance(project).openFile(file, false, true)
val editor = tabsManager.openEditorLogTab("", false, null)
VcsLogEditorUtil.findVcsLogUi(editor,MainVcsLogUi::class.java)
} else {
createLogUi(getMainLogUiFactory(MAIN_LOG_ID, null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ internal class VcsLogTabsManager(
throw UnsupportedOperationException("Only log in editor or tool window is supported")
}

private fun openEditorLogTab(tabId: String, focus: Boolean, filters: VcsLogFilterCollection?): Array<FileEditor> {
val file = VcsLogVirtualFileSystem.Holder.getInstance().createVcsLogFile(project, tabId, filters)
fun openEditorLogTab(tabId: String, focus: Boolean, filters: VcsLogFilterCollection?): Array<FileEditor> {
val file = VcsLogVirtualFileSystem.Holder.getInstance().createVcsLogFile(project, tabId, filters, uiProperties.tabs.isNotEmpty())
installFilesListener()
uiProperties.addTab(tabId, VcsLogTabLocation.EDITOR)
return FileEditorManager.getInstance(project).openFile(file, focus, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class CanCloseVirtualLogFile: VirtualFilePreCloseCheck {
* don't allow the first vcs log window to be closed
*/
override fun canCloseFile(file: VirtualFile): Boolean {
return file !is DefaultVcsLogFile || !file.isFirstLogFile
return file !is DefaultVcsLogFile || file.canClose
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import javax.swing.JComponent
internal class DefaultVcsLogFile(
private val pathId: VcsLogVirtualFileSystem.VcsLogComplexPath,
private var filters: VcsLogFilterCollection? = null,
// the first log file always gets created with an empty log ID in IdeVcsLogManager.createUi, which should never be closable
var canClose: Boolean = pathId.logId != ""
) :
VcsLogFile(VcsLogTabsUtil.getFullName(pathId.logId)), VirtualFilePathWrapper { //NON-NLS not displayed

Expand Down Expand Up @@ -97,9 +99,6 @@ internal class DefaultVcsLogFile(
return tabId.hashCode()
}

// the first log file always gets created with an empty log ID in IdeVcsLogManager.createUi
val isFirstLogFile by lazy { pathId.logId == "" }

companion object {
private val LOG = logger<DefaultVcsLogFile>()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ internal class VcsLogVirtualFileSystem :
ComplexPathVirtualFileSystem<VcsLogVirtualFileSystem.VcsLogComplexPath>(GsonComplexPathSerializer(VcsLogComplexPath::class.java)) {

override fun findOrCreateFile(project: Project, path: VcsLogComplexPath): VirtualFile {
return createVcsLogFile(path, null)
return createVcsLogFile(path, null, true) // TODO: should this ever be false?
}

fun createVcsLogFile(project: Project, tabId: String, filters: VcsLogFilterCollection?): VirtualFile {
return createVcsLogFile(VcsLogComplexPath(project.locationHash, project.locationHash, tabId), filters)
/**
* @param canClose if `null`, infer whether the file can be closed based on whether it's the initially opened one.
*/
fun createVcsLogFile(project: Project, tabId: String, filters: VcsLogFilterCollection?, canClose: Boolean): VirtualFile {
return createVcsLogFile(VcsLogComplexPath(project.locationHash, project.locationHash, tabId), filters, canClose)
}

private fun createVcsLogFile(pathId: VcsLogComplexPath, filters: VcsLogFilterCollection?): DefaultVcsLogFile {
return DefaultVcsLogFile(pathId, filters)
private fun createVcsLogFile(pathId: VcsLogComplexPath, filters: VcsLogFilterCollection?, canClose: Boolean): DefaultVcsLogFile {
return DefaultVcsLogFile(pathId, filters, canClose)
}

override fun getProtocol(): String = Holder.PROTOCOL
Expand Down
Loading