Skip to content

Commit 7b82457

Browse files
committed
keep only minimal changes for the bugfix
1 parent 7b9a9e2 commit 7b82457

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/main/java/com/tang/intellij/lua/editor/LuaGutterCacheListener.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.tang.intellij.lua.editor
22

3-
import com.cppcxy.ide.lsp.GutterInfo
43
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
54
import com.intellij.openapi.Disposable
65
import com.intellij.openapi.application.ApplicationManager
@@ -21,15 +20,14 @@ import com.intellij.openapi.vfs.VirtualFileManager
2120
import com.intellij.openapi.vfs.newvfs.BulkFileListener
2221
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
2322
import com.intellij.psi.PsiManager
24-
import com.tang.intellij.lua.lang.LuaFileType
2523
import com.tang.intellij.lua.psi.LuaPsiFile
2624
import java.util.concurrent.ConcurrentHashMap
2725

2826
/**
2927
* Manager to handle gutter cache and trigger updates
3028
*/
3129
object LuaGutterCacheManager {
32-
private val gutterCache = ConcurrentHashMap<String, List<GutterInfo>>()
30+
private val gutterCache = ConcurrentHashMap<String, List<com.cppcxy.ide.lsp.GutterInfo>>()
3331
private val cacheTimestamps = ConcurrentHashMap<String, Long>()
3432

3533
fun clearCache(uri: String) {
@@ -42,11 +40,11 @@ object LuaGutterCacheManager {
4240
cacheTimestamps.clear()
4341
}
4442

45-
fun getCache(uri: String): List<GutterInfo>? {
43+
fun getCache(uri: String): List<com.cppcxy.ide.lsp.GutterInfo>? {
4644
return gutterCache[uri]
4745
}
4846

49-
fun setCache(uri: String, infos: List<GutterInfo>) {
47+
fun setCache(uri: String, infos: List<com.cppcxy.ide.lsp.GutterInfo>) {
5048
gutterCache[uri] = infos
5149
cacheTimestamps[uri] = System.currentTimeMillis()
5250
}
@@ -72,7 +70,7 @@ class LuaDocumentListener(private val project: Project) : DocumentListener {
7270
val document = event.document
7371
val file = FileDocumentManager.getInstance().getFile(document) ?: return
7472

75-
if (file.fileType !== LuaFileType.INSTANCE) return
73+
if (file.extension != "lua") return
7674

7775
// Clear cache immediately for instant refresh
7876
LuaGutterCacheManager.clearCache(file.url)
@@ -125,7 +123,7 @@ class LuaDocumentListener(private val project: Project) : DocumentListener {
125123
*/
126124
class LuaFileEditorListener(private val project: Project) : FileEditorManagerListener {
127125
override fun fileOpened(source: FileEditorManager, file: VirtualFile) {
128-
if (file.fileType === LuaFileType.INSTANCE) {
126+
if (file.extension == "lua") {
129127
// Clear cache for newly opened file to ensure fresh data
130128
LuaGutterCacheManager.clearCache(file.url)
131129

@@ -151,7 +149,7 @@ class LuaGutterCacheStartupActivity : ProjectActivity {
151149
val appConnection = ApplicationManager.getApplication().messageBus.connect(parentDisposable)
152150
val projectConnection = project.messageBus.connect(parentDisposable)
153151

154-
// Listen to document changes for all editors via the multicaster to avoid duplicate registrations
152+
// Listen to editor creation events to attach document listener
155153
EditorFactory.getInstance()
156154
.eventMulticaster
157155
.addDocumentListener(documentListener, parentDisposable)
@@ -169,7 +167,7 @@ class LuaGutterCacheStartupActivity : ProjectActivity {
169167
override fun after(events: List<VFileEvent>) {
170168
for (event in events) {
171169
val file = event.file
172-
if (file != null && file.fileType === LuaFileType.INSTANCE) {
170+
if (file != null && file.extension == "lua") {
173171
// Clear cache when file changes externally
174172
LuaGutterCacheManager.clearCache(file.url)
175173

0 commit comments

Comments
 (0)