Skip to content

Commit f701f81

Browse files
committed
fix(devti): handle null afterName in AgentStateService
- Add null check for patch.afterName before processing- Remove unused imports for Path and ArrayList
1 parent 4586b0f commit f701f81

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

core/src/main/kotlin/cc/unitmesh/devti/observer/agent/AgentStateService.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import com.intellij.vcsUtil.VcsUtil
3232
import org.jetbrains.annotations.NonNls
3333
import java.io.File
3434
import java.io.IOException
35-
import java.nio.file.Path
36-
import java.util.*
3735

3836
@Service(Service.Level.PROJECT)
3937
class AgentStateService(val project: Project) {
@@ -53,10 +51,12 @@ class AgentStateService(val project: Project) {
5351

5452
fun addToChange(patch: TextFilePatch) {
5553
val baseDir = File(project.basePath!!)
56-
val newChangePath = getAbsolutePath(baseDir, patch.afterName).canonicalPath
57-
state.changes.removeIf {
58-
val afterRevision = it.afterRevision
59-
afterRevision != null && File(afterRevision.file.path).canonicalPath == newChangePath
54+
if (patch.afterName != null) {
55+
val newChangePath = getAbsolutePath(baseDir, patch.afterName).canonicalPath
56+
state.changes.removeIf {
57+
val afterRevision = it.afterRevision
58+
afterRevision != null && File(afterRevision.file.path).canonicalPath == newChangePath
59+
}
6060
}
6161

6262
val change = createChange(patch)

0 commit comments

Comments
 (0)