mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-20 01:02:02 +00:00
fix: header link anomalies on invalid paths
This commit is contained in:
parent
f3010ff5dc
commit
690bdf821b
3 changed files with 14 additions and 15 deletions
|
|
@ -33,13 +33,6 @@ class AutoApplyAction(
|
|||
}
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
if (virtualFile == null && filePath != null) {
|
||||
anActionLink.isEnabled = false
|
||||
anActionLink.isVisible = false
|
||||
anActionLink.toolTipText = "No file created"
|
||||
return
|
||||
}
|
||||
|
||||
if (virtualFile != null) {
|
||||
anActionLink.text = "Apply"
|
||||
anActionLink.isEnabled = true
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.intellij.openapi.vfs.LocalFileSystem
|
|||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.readText
|
||||
import com.intellij.ui.ColorUtil
|
||||
import com.intellij.util.application
|
||||
import com.intellij.util.ui.JBUI
|
||||
import com.intellij.vcsUtil.VcsUtil.getVirtualFile
|
||||
import ee.carlrobert.codegpt.CodeGPTKeys
|
||||
|
|
@ -37,7 +38,6 @@ object EditorFactory {
|
|||
fun createEditor(project: Project, segment: Segment): EditorEx {
|
||||
val content = segment.content
|
||||
val languageMapping = FileUtil.findLanguageExtensionMapping(segment.language)
|
||||
val virtualFile = segment.filePath?.let { getVirtualFile(it)}
|
||||
val isDiffType = isDiffType(segment, content)
|
||||
return invokeAndWaitIfNeeded {
|
||||
val editor = if (isDiffType) {
|
||||
|
|
@ -47,12 +47,13 @@ object EditorFactory {
|
|||
EditorUtil.createEditor(project, languageMapping.value, content)
|
||||
} as EditorEx
|
||||
segment.filePath?.let { filePath ->
|
||||
CodeGPTKeys.TOOLWINDOW_EDITOR_FILE_DETAILS.set(
|
||||
editor,
|
||||
ToolWindowEditorFileDetails(filePath, virtualFile)
|
||||
)
|
||||
application.executeOnPooledThread {
|
||||
CodeGPTKeys.TOOLWINDOW_EDITOR_FILE_DETAILS.set(
|
||||
editor,
|
||||
ToolWindowEditorFileDetails(filePath, getVirtualFile(filePath))
|
||||
)
|
||||
}
|
||||
DiffSyncManager.registerEditor(filePath, editor)
|
||||
|
||||
}
|
||||
editor
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import java.awt.BorderLayout
|
|||
import java.awt.Dimension
|
||||
import java.awt.FlowLayout
|
||||
import java.io.File
|
||||
import javax.swing.Box
|
||||
import javax.swing.BoxLayout
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JPanel
|
||||
|
|
@ -108,10 +107,16 @@ abstract class HeaderPanel(protected val config: HeaderConfig) : BorderLayoutPan
|
|||
minimumSize = Dimension(preferredSize.width, 32)
|
||||
}
|
||||
|
||||
private fun isProjectPath(path: String): Boolean {
|
||||
return config.project.basePath?.let {
|
||||
return path.startsWith(it)
|
||||
} ?: false
|
||||
}
|
||||
|
||||
private fun createLeftPanel(virtualFile: VirtualFile?): JComponent {
|
||||
val filePath = config.filePath
|
||||
val linkOrLabel = when {
|
||||
filePath == null -> createLanguageLabel()
|
||||
filePath == null || !isProjectPath(filePath) -> createLanguageLabel()
|
||||
virtualFile == null -> createNewFileLink(filePath, config.editorEx)
|
||||
else -> createFileLinkPanel(virtualFile)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue