@@ -9,15 +9,14 @@ import com.github.blarc.ai.commits.intellij.plugin.createColumn
99import com.github.blarc.ai.commits.intellij.plugin.notBlank
1010import com.github.blarc.ai.commits.intellij.plugin.settings.AppSettings2
1111import com.github.blarc.ai.commits.intellij.plugin.unique
12- import com.intellij.dvcs.repo.VcsRepositoryManager
1312import com.intellij.ide.DataManager
1413import com.intellij.openapi.actionSystem.CommonDataKeys
1514import com.intellij.openapi.application.EDT
1615import com.intellij.openapi.application.ModalityState
1716import com.intellij.openapi.application.asContextElement
18- import com.intellij.openapi.diagnostic.Logger
1917import com.intellij.openapi.project.Project
2018import com.intellij.openapi.ui.DialogWrapper
19+ import com.intellij.openapi.vcs.changes.ChangeListManager
2120import com.intellij.ui.components.JBTextArea
2221import com.intellij.ui.components.JBTextField
2322import com.intellij.ui.dsl.builder.Align
@@ -26,7 +25,6 @@ import com.intellij.ui.dsl.builder.panel
2625import com.intellij.ui.dsl.builder.text
2726import com.intellij.ui.table.TableView
2827import com.intellij.util.ui.ListTableModel
29- import git4idea.branch.GitBranchWorker
3028import kotlinx.coroutines.CoroutineScope
3129import kotlinx.coroutines.Dispatchers
3230import kotlinx.coroutines.launch
@@ -122,7 +120,6 @@ class PromptTable(private val cs: CoroutineScope) {
122120 var branch: String? = null
123121 lateinit var diff: String
124122 lateinit var project: Project
125- private val logger = Logger .getInstance(PromptDialog ::class .java)
126123
127124 init {
128125 setSize(AppSettings2 .instance.promptDialogWidth, AppSettings2 .instance.promptDialogHeight)
@@ -210,29 +207,7 @@ class PromptTable(private val cs: CoroutineScope) {
210207 }
211208
212209 private fun getChangesAndSetPreview (project : Project ) = cs.launch(Dispatchers .IO + ModalityState .stateForComponent(rootPane).asContextElement()) {
213- val repositories = VcsRepositoryManager .getInstance(project).repositories
214- if (repositories.isEmpty()) {
215- logger.warn(" No Git repositories found in the project." )
216- return @launch
217- }
218-
219- val changes = repositories.asSequence()
220- .filter { it.currentBranchName != null }
221- .flatMap { repository ->
222- val branchName = repository.currentBranchName!!
223- try {
224- GitBranchWorker .loadTotalDiff(repository, branchName).asSequence()
225- } catch (e: Exception ) {
226- logger.error(" Failed to load diff for branch '$branchName ' in repository: ${repository.presentableUrl} " , e)
227- emptySequence()
228- }
229- }
230- .toList()
231-
232- if (changes.isEmpty()) {
233- logger.warn(" No changes found for the current branch." )
234- }
235-
210+ val changes = ChangeListManager .getInstance(project).allChanges.toList()
236211 branch = getCommonBranch(changes, project)
237212 diff = computeDiff(changes, true , project)
238213
0 commit comments