fix: compatibility issue

This commit is contained in:
Carl-Robert Linnupuu 2025-02-25 23:18:22 +00:00
parent a120ce544f
commit 0e93c38e29
2 changed files with 14 additions and 11 deletions

View file

@ -13,7 +13,7 @@ import ee.carlrobert.codegpt.settings.service.ServiceType
import ee.carlrobert.codegpt.settings.service.codegpt.CodeGPTService
import ee.carlrobert.codegpt.toolwindow.chat.ui.textarea.AttachImageNotifier
import ee.carlrobert.codegpt.ui.OverlayUtil
import io.ktor.util.*
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.io.path.absolutePathString
@ -34,7 +34,7 @@ class CodeGPTProjectActivity : ProjectActivity {
) {
val desktopPath = Paths.get(System.getProperty("user.home"), "Desktop")
project.service<FileWatcher>().watch(desktopPath) {
if (watchExtensions.contains(it.extension.lowercase())) {
if (watchExtensions.contains(getFileExtension(it))) {
showImageAttachmentNotification(
project,
desktopPath.resolve(it).absolutePathString()
@ -44,6 +44,16 @@ class CodeGPTProjectActivity : ProjectActivity {
}
}
private fun getFileExtension(path: Path): String {
val fileName = path.fileName.toString()
val lastIndexOfDot = fileName.lastIndexOf('.')
return if (lastIndexOfDot != -1) {
fileName.substring(lastIndexOfDot + 1).lowercase()
} else {
""
}
}
private fun showImageAttachmentNotification(project: Project, filePath: String) {
OverlayUtil.getDefaultNotification(
CodeGPTBundle.get("imageAttachmentNotification.content"),