Skip to content

Commit 574fca6

Browse files
committed
svg
1 parent 4e9659c commit 574fca6

2 files changed

Lines changed: 57 additions & 23 deletions

File tree

src/main/kotlin/com/company/plugin/navigation/ZyGotoDeclarationHandler.kt

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,28 +133,22 @@ class ZyGotoDeclarationHandler : GotoDeclarationHandler {
133133
try {
134134
LOG.debug("Navigating to file=${file.path}, offset=$offset")
135135

136-
// 安全的延迟跳转,确保编辑器完全初始化
137-
ApplicationManager.getApplication().invokeLater {
136+
// 直接跳转,LSP更新很快,不需要额外延迟
137+
val descriptor = OpenFileDescriptor(element.project, file, offset)
138+
if (descriptor.canNavigate()) {
139+
descriptor.navigate(requestFocus)
140+
} else {
141+
LOG.warn("Cannot navigate to ${file.path}:$offset")
142+
// 降级到基本的文件打开
138143
try {
139-
val descriptor = OpenFileDescriptor(element.project, file, offset)
140-
if (descriptor.canNavigate()) {
141-
descriptor.navigate(requestFocus)
142-
} else {
143-
LOG.warn("Cannot navigate to ${file.path}:$offset")
144-
}
145-
} catch (e: Exception) {
146-
LOG.error("Failed to navigate to position after delay", e)
147-
// 降级到基本的文件打开
148-
try {
149-
val basicDescriptor = OpenFileDescriptor(element.project, file)
150-
basicDescriptor.navigate(requestFocus)
151-
} catch (fallbackException: Exception) {
152-
LOG.error("Fallback navigation also failed", fallbackException)
153-
}
144+
val basicDescriptor = OpenFileDescriptor(element.project, file)
145+
basicDescriptor.navigate(requestFocus)
146+
} catch (fallbackException: Exception) {
147+
LOG.error("Fallback navigation also failed", fallbackException)
154148
}
155149
}
156150
} catch (e: Exception) {
157-
LOG.error("Failed to schedule navigation", e)
151+
LOG.error("Failed to navigate", e)
158152
}
159153
}
160154
}
Lines changed: 45 additions & 5 deletions
Loading

0 commit comments

Comments
 (0)