Skip to content

fix: fall back to next LS when formatting returns no edits#1433

Merged
sebthom merged 1 commit intoeclipse-lsp4e:mainfrom
sebthom:formatting
Dec 1, 2025
Merged

fix: fall back to next LS when formatting returns no edits#1433
sebthom merged 1 commit intoeclipse-lsp4e:mainfrom
sebthom:formatting

Conversation

@sebthom
Copy link
Copy Markdown
Member

@sebthom sebthom commented Nov 28, 2025

In WildWebDeveloper it is currently not possible to format .vue files because VUE and TS LS are both launched and the TS LS processes the format request first and returns an empty list of edits for .vue documents.

LSP4E’s LSPFormatter currently wraps the result of each server call into VersionedEdits before passing it to LanguageServers.computeFirst(...), so computeFirst only sees a non-null object and cannot detect that the underlying edit list is empty. As a result, the TS LS “wins” the formatting request for .vue files and the Vue LS is never consulted.

This PR changes LSPFormatter.requestFormatting(...) to let computeFirst operate on the raw List<? extends TextEdit> returned by each language server. Only after computeFirst has selected a non-empty edit list do we wrap it into VersionedEdits. This allows computeFirst’s existing logic (which treats null and empty collections as “no result”) to work as intended: servers that advertise formatting but return no edits are skipped, and the next server with real edits (e.g. the Vue LS) is used instead.

The behavior for single-server scenarios is unchanged (an empty edit list still means “no formatting applied”), while multi-server setups like WildWebDeveloper (TS + Vue) now correctly fall back to the Vue language server for .vue formatting.

@sebthom sebthom merged commit 4e5c4a9 into eclipse-lsp4e:main Dec 1, 2025
12 checks passed
@sebthom
Copy link
Copy Markdown
Member Author

sebthom commented Dec 1, 2025

@rubenporras we should make sure this fix gets part of the simrel. so before we merge any features we should create a fix release before end of this week and register it with simrel 2025-12. I can do the release if you want.

https://github.com/eclipse-simrel/.github/blob/main/wiki/SimRel/2025-12.md

@rubenporras
Copy link
Copy Markdown
Contributor

@sebthom , I think it would be nice to have some version of #1442 as well. Do you think you can update your PR today?

Afterwards, I do not mind to do the release as I already know very well how to do it, but thanks for your offer.

@rubenporras
Copy link
Copy Markdown
Contributor

@sebthom , I have merged eclipse-simrel/simrel.build#1163. I am not sure if this is enough, but if not, would you mind taking over if we need to submit to a different branch?

@sebthom sebthom deleted the formatting branch December 2, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants