-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Bug Report: Kotlin Language Server interferes with edit_file tool causing data loss and file reversions
Summary:
When the Kotlin Language Server is enabled, Zed's edit_file tool exhibits severe malfunctioning behavior on build.gradle.kts files, causing unwanted changes, data loss, and file reversions to cached/stale versions.
Environment:
- OS: Linux
- File type:
build.gradle.kts(Kotlin Gradle build script) - LSP: kotlin-language-server configured in
.zed/settings.json
Reproduction Steps:
- Open a project with a
build.gradle.ktsfile - Configure Kotlin Language Server in
.zed/settings.json:{ "lsp": { "kotlin-language-server": { "settings": { "compiler": { "jvm": { "target": "17" } } } } } } - Make manual changes to
build.gradle.kts(e.g., replace hardcoded dependency versions with Gradle version catalog references) - Attempt any edit using
edit_filetool, even adding a simple comment
Expected Behavior:
The edit_file tool should make only the requested changes to the current file state on disk.
Actual Behavior:
- The tool reverts all manual changes back to an old cached version
- Makes massive unwanted modifications (e.g., changing plugin versions, reverting dependency references, adding unrequested code)
- Sometimes reports "No edits were made" when changes should have been applied
- Completely ignores the current file state on disk
Key Evidence:
- File on disk:
kotlin("multiplatform") version "2.2.0"(current) - After edit_file:
kotlin("multiplatform") version "2.1.0"(reverted to old version) - Manual version catalog changes: Completely reverted to hardcoded versions
- Other Kotlin files:
edit_fileworks normally on regular.ktsource files
Workaround Discovered:
Setting "enable_language_server": false in .zed/settings.json completely resolves the issue. With LSP disabled, edit_file works correctly and makes only the requested changes.
Root Cause Analysis:
The Kotlin Language Server appears to maintain its own cached version of build.gradle.kts files and interferes with file editing operations, overriding changes with stale data.
Impact:
- Critical data loss risk: Manual work gets silently reverted
- Development workflow disruption: Cannot reliably edit Gradle build files
- Tool unreliability:
edit_filebecomes unusable for Kotlin projects with LSP enabled
Expected Fix:
The edit_file tool should either:
- Coordinate with LSP servers to ensure file state consistency, or
- Temporarily disable LSP interference during editing operations, or
- Always read the actual file state from disk rather than from LSP caches
This appears to be a critical integration issue between Zed's editing tools and language server protocol implementation.