@@ -13,7 +13,7 @@ import ee.carlrobert.codegpt.settings.service.ServiceType
1313import ee.carlrobert.codegpt.settings.service.codegpt.CodeGPTService
1414import ee.carlrobert.codegpt.toolwindow.chat.ui.textarea.AttachImageNotifier
1515import ee.carlrobert.codegpt.ui.OverlayUtil
16- import io.ktor.util.*
16+ import java.nio.file.Path
1717import java.nio.file.Paths
1818import kotlin.io.path.absolutePathString
1919
@@ -34,7 +34,7 @@ class CodeGPTProjectActivity : ProjectActivity {
3434 ) {
3535 val desktopPath = Paths .get(System .getProperty(" user.home" ), " Desktop" )
3636 project.service<FileWatcher >().watch(desktopPath) {
37- if (watchExtensions.contains(it.extension.lowercase( ))) {
37+ if (watchExtensions.contains(getFileExtension(it ))) {
3838 showImageAttachmentNotification(
3939 project,
4040 desktopPath.resolve(it).absolutePathString()
@@ -44,6 +44,16 @@ class CodeGPTProjectActivity : ProjectActivity {
4444 }
4545 }
4646
47+ private fun getFileExtension (path : Path ): String {
48+ val fileName = path.fileName.toString()
49+ val lastIndexOfDot = fileName.lastIndexOf(' .' )
50+ return if (lastIndexOfDot != - 1 ) {
51+ fileName.substring(lastIndexOfDot + 1 ).lowercase()
52+ } else {
53+ " "
54+ }
55+ }
56+
4757 private fun showImageAttachmentNotification (project : Project , filePath : String ) {
4858 OverlayUtil .getDefaultNotification(
4959 CodeGPTBundle .get(" imageAttachmentNotification.content" ),
0 commit comments