Skip to content

Commit cdb93e0

Browse files
committed
wip
1 parent 33700b2 commit cdb93e0

5 files changed

Lines changed: 14 additions & 16 deletions

File tree

platform/vcs-log/impl/src/com/intellij/vcs/log/impl/IdeVcsLogManager.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package com.intellij.vcs.log.impl
44
import com.intellij.openapi.application.EdtImmediate
55
import com.intellij.openapi.application.UiImmediate
66
import com.intellij.openapi.components.service
7-
import com.intellij.openapi.fileEditor.FileEditorManager
87
import com.intellij.openapi.project.Project
98
import com.intellij.openapi.util.Disposer
109
import com.intellij.openapi.vfs.VirtualFile
@@ -22,7 +21,6 @@ import com.intellij.vcs.log.impl.VcsLogNavigationUtil.showCommit
2221
import com.intellij.vcs.log.impl.VcsLogNavigationUtil.showCommitSync
2322
import com.intellij.vcs.log.ui.MainVcsLogUi
2423
import com.intellij.vcs.log.ui.VcsLogUiEx
25-
import com.intellij.vcs.log.ui.editor.VcsLogVirtualFileSystem
2624
import com.intellij.vcs.log.util.VcsLogUtil
2725
import com.intellij.vcs.log.visible.filters.VcsLogFilterObject
2826
import kotlinx.coroutines.CoroutineScope
@@ -62,9 +60,7 @@ internal class IdeVcsLogManager(
6260
mainUiHolderState.collect { holder ->
6361
val showLogInEditorWindow = service<VcsLogApplicationSettings>()[CommonUiProperties.SHOW_IN_EDITOR]
6462
val ui = if (showLogInEditorWindow) {
65-
val file = VcsLogVirtualFileSystem.Holder.getInstance().
66-
createVcsLogFile(project, "", null)
67-
val editor = FileEditorManager.getInstance(project).openFile(file, false, true)
63+
val editor = tabsManager.openEditorLogTab("", false, null)
6864
VcsLogEditorUtil.findVcsLogUi(editor,MainVcsLogUi::class.java)
6965
} else {
7066
createLogUi(getMainLogUiFactory(MAIN_LOG_ID, null))

platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogTabsManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ internal class VcsLogTabsManager(
135135
throw UnsupportedOperationException("Only log in editor or tool window is supported")
136136
}
137137

138-
private fun openEditorLogTab(tabId: String, focus: Boolean, filters: VcsLogFilterCollection?): Array<FileEditor> {
139-
val file = VcsLogVirtualFileSystem.Holder.getInstance().createVcsLogFile(project, tabId, filters)
138+
fun openEditorLogTab(tabId: String, focus: Boolean, filters: VcsLogFilterCollection?): Array<FileEditor> {
139+
val file = VcsLogVirtualFileSystem.Holder.getInstance().createVcsLogFile(project, tabId, filters, uiProperties.tabs.isNotEmpty())
140140
installFilesListener()
141141
uiProperties.addTab(tabId, VcsLogTabLocation.EDITOR)
142142
return FileEditorManager.getInstance(project).openFile(file, focus, true)

platform/vcs-log/impl/src/com/intellij/vcs/log/ui/CanCloseVirtualLogFile.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ class CanCloseVirtualLogFile: VirtualFilePreCloseCheck {
1010
* don't allow the first vcs log window to be closed
1111
*/
1212
override fun canCloseFile(file: VirtualFile): Boolean {
13-
return file !is DefaultVcsLogFile || !file.isFirstLogFile
13+
return file !is DefaultVcsLogFile || file.canClose
1414
}
1515
}

platform/vcs-log/impl/src/com/intellij/vcs/log/ui/editor/DefaultVcsLogFile.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import javax.swing.JComponent
3636
internal class DefaultVcsLogFile(
3737
private val pathId: VcsLogVirtualFileSystem.VcsLogComplexPath,
3838
private var filters: VcsLogFilterCollection? = null,
39+
// the first log file always gets created with an empty log ID in IdeVcsLogManager.createUi, which should never be closable
40+
var canClose: Boolean = pathId.logId != ""
3941
) :
4042
VcsLogFile(VcsLogTabsUtil.getFullName(pathId.logId)), VirtualFilePathWrapper { //NON-NLS not displayed
4143

@@ -97,9 +99,6 @@ internal class DefaultVcsLogFile(
9799
return tabId.hashCode()
98100
}
99101

100-
// the first log file always gets created with an empty log ID in IdeVcsLogManager.createUi
101-
val isFirstLogFile by lazy { pathId.logId == "" }
102-
103102
companion object {
104103
private val LOG = logger<DefaultVcsLogFile>()
105104
}

platform/vcs-log/impl/src/com/intellij/vcs/log/ui/editor/VcsLogVirtualFileSystem.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ internal class VcsLogVirtualFileSystem :
1313
ComplexPathVirtualFileSystem<VcsLogVirtualFileSystem.VcsLogComplexPath>(GsonComplexPathSerializer(VcsLogComplexPath::class.java)) {
1414

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

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

23-
private fun createVcsLogFile(pathId: VcsLogComplexPath, filters: VcsLogFilterCollection?): DefaultVcsLogFile {
24-
return DefaultVcsLogFile(pathId, filters)
26+
private fun createVcsLogFile(pathId: VcsLogComplexPath, filters: VcsLogFilterCollection?, canClose: Boolean): DefaultVcsLogFile {
27+
return DefaultVcsLogFile(pathId, filters, canClose)
2528
}
2629

2730
override fun getProtocol(): String = Holder.PROTOCOL

0 commit comments

Comments
 (0)