You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "DavidLiedle (via GitHub)" <gi...@apache.org> on 2026/08/27 21:34:19 UTC

[I] lsp.client: no per-file server binding (project×mime only), and rename merges WorkspaceEdits from every bound server [netbeans]

DavidLiedle opened a new issue, #9582:
URL: https://github.com/apache/netbeans/issues/9582

   ### Apache NetBeans version
   
   Apache NetBeans 25 (observed on RELEASE300, still present on RELEASE310)
   
   ### Bug description
   
   Two related limitations in ide/lsp.client that together make it impossible to attach a language server to a *subset* of files sharing a MIME type — and make it hazardous for two servers to share a mime at all:
   
   **1. Bindings are per PROJECT × MIME, never per file.** `LSPBindings` keys server bindings by (project, mime). `LanguageServerProvider.startServer` receives no file/document context, so a provider cannot decide per file whether to attach. Concrete case: Angular CLI ≥ 21 generates *suffixless* templates (`widget.html` beside `widget.ts`), which want the Angular Language Service — but binding `ngserver` under `text/html` attaches it to **every** html file in the project, plain documents included.
   
   **2. Rename applies WorkspaceEdits from EVERY bound server.** When two servers are bound to one mime (which `lookupAll` deliberately allows — useful for eslint-style diagnostic servers), the platform's rename collects and applies edits from **all** of them. With two servers that both implement rename (e.g. `ngserver` beside `typescript-language-server` on `text/typescript`), every rename is applied twice — we measured real double-renames before suppressing one server's mime binding entirely.
   
   Also worth noting: the bindings consult the FileObject's resolver-assigned mime, not the document mime — a `DataObject` that pins the editor content type via the public `CloneableEditorSupport.setMIMEType` gets the full editor surface (coloring, keybindings, popup) for the new mime, but LSP still binds by the file mime, so the two disagree.
   
   ### Steps to reproduce
   
   For (2): register two `LanguageServerProvider`s for one mime where both back rename; rename a symbol; observe the edit applied twice.
   
   For (1): attempt to attach a server to only those `text/html` files matching a project-structural condition — there is no seam: `startServer` has no file, and mime-folder registration is all-or-nothing per project.
   
   ### Expected behavior
   
   Either of these would unblock the use case safely:
   
   - a per-file consultation in the provider SPI (e.g. the provider sees the triggering FileObject/document and may decline), or
   - bindings consulting the document mime (so `setMIMEType` reroutes LSP together with the editor surface), or
   - rename asking one authoritative server per capability instead of merging all bindings' edits.
   
   ### Context
   
   Found while building NMOX Studio (Apache-2.0, NetBeans-Platform based): https://github.com/NMOX/NMOX-Studio — engineering ledger entries 81/82 (docs/engineering/tech-debt.md) carry the measurements and the decompiled details. Related: #9581 (multi-mime provider registrations and the instance-keyed reuse map). Happy to test patches or provide more detail.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists