Skip to content

Commit d5f7da3

Browse files
committed
refactor(editor): remove unused scroll-related code
- Delete unused `scrollToSrcOffset` function in `McpPreviewEditor` - Remove `VisibleAreaListener` implementation and related imports in `McpFileEditorWithPreview`
1 parent bfb7c2d commit d5f7da3

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

core/src/main/kotlin/cc/unitmesh/devti/mcp/editor/McpFileEditorWithPreview.kt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ package cc.unitmesh.devti.mcp.editor
22

33
import com.intellij.icons.AllIcons
44
import com.intellij.openapi.actionSystem.*
5-
import com.intellij.openapi.editor.event.VisibleAreaEvent
6-
import com.intellij.openapi.editor.event.VisibleAreaListener
7-
import com.intellij.openapi.editor.ex.util.EditorUtil
8-
import com.intellij.openapi.editor.impl.EditorImpl
95
import com.intellij.openapi.fileEditor.TextEditor
106
import com.intellij.openapi.fileEditor.TextEditorWithPreview
117
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider
@@ -22,29 +18,12 @@ class McpFileEditorWithPreview(
2218

2319
init {
2420
preview.setMainEditor(ourEditor.editor)
25-
ourEditor.editor.scrollingModel.addVisibleAreaListener(MyVisibleAreaListener(), this)
2621
}
2722

2823
override fun dispose() {
2924
TextEditorProvider.getInstance().disposeEditor(ourEditor)
3025
}
3126

32-
inner class MyVisibleAreaListener : VisibleAreaListener {
33-
private var previousLine = 0
34-
35-
override fun visibleAreaChanged(event: VisibleAreaEvent) {
36-
val editor = event.editor
37-
val y = editor.scrollingModel.verticalScrollOffset
38-
val currentLine = if (editor is EditorImpl) editor.yToVisualLine(y) else y / editor.lineHeight
39-
if (currentLine == previousLine) {
40-
return
41-
}
42-
43-
previousLine = currentLine
44-
preview.scrollToSrcOffset(EditorUtil.getVisualLineEndOffset(editor, currentLine))
45-
}
46-
}
47-
4827
override fun createToolbar(): ActionToolbar {
4928
return ActionManager.getInstance()
5029
.createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, createActionGroup(project), true)

core/src/main/kotlin/cc/unitmesh/devti/mcp/editor/McpPreviewEditor.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,6 @@ open class McpPreviewEditor(
289289
mainEditor.value = editor
290290
}
291291

292-
fun scrollToSrcOffset(offset: Int) {
293-
// Implementation here
294-
}
295-
296292
override fun getComponent(): JComponent = mainPanel
297293
override fun getName(): String = "MCP Preview"
298294
override fun setState(state: FileEditorState) {}

0 commit comments

Comments
 (0)