Repository navigation
fix: LSP4IJ's Enter between braces applies only to the files of language servers, without the deprecated EnterBetweenBracesHandler - #2332
Merged
lagergren merged 1 commit intoNov 28, 2026
Conversation
…age servers, without the deprecated EnterBetweenBracesHandler LSPEditorImprovementsEnterBetweenBracesHandler, the workaround for IJPL-159454, extended the deprecated EnterBetweenBracesHandler. That class only overrides the isApplicable of EnterBetweenBracesFinalHandler, which the platform registers with the id EnterBetweenBracesHandler, so that it uses the default EnterBetweenBracesDelegate instead of the one of the file's language. The replacement which the deprecation names, an EnterBetweenBracesDelegate of a language, can't do what the workaround does: it rewrites the braces and their indent once the Enter is done, in postProcessEnter. The handler now extends EnterHandlerDelegateAdapter, and runs a private EnterBetweenBracesFinalHandler first on the files that it fixes, as the deprecated class did: the files of language servers, of an abstract file type or a TextMate one, whose language server enables the fix. No language of these files has an EnterBetweenBracesDelegate in 2024.2 to 2026.3, so the default one decides, as before, and their Enter doesn't change. It splits no braces of a TextMate file, whose braces are in the same element: the fix is postProcessEnter's. Ordered first, and extending the platform's handler, it also split the braces of every other file, before the Enter handlers that ask to run before the platform's, such as those of Kotlin, Java and Groovy. It now leaves those files to the platform's handler, which splits their braces where it is registered. The new EnterBetweenBracesOrderTest records what an Enter handler ordered before the platform's sees in a JSON file, which has no language server there: it saw the braces split already, and sees them as they were now. The platform's handler still splits them. Part of redhat-developer#1971
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2332 +/- ##
==========================================
+ Coverage 58.65% 58.66% +0.01%
==========================================
Files 849 849
Lines 36709 36719 +10
Branches 5766 7609 +1843
==========================================
+ Hits 21530 21541 +11
+ Misses 12179 12177 -2
- Partials 3000 3001 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
@coderabbitai review |
1 similar comment
Collaborator
Author
|
@coderabbitai review |
Action performed
|
Action not completed
|
19 of 35 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1971
LSPEditorImprovementsEnterBetweenBracesHandler, LSP4IJ's workaround for IJPL-159454, no longer extends the deprecatedEnterBetweenBracesHandler, which the plugin verifier reports on every release from 2024.2 to 2026.3. It works the same on all of them, without reflection. One commit, for 0.30.2.Behaviour change
first, and extending the platform's Enter between braces, the handler split the braces of every file, before the Enter handlers that ask to run before the platform's, such as those of Kotlin, Java's Javadoc snippets and text blocks, and Groovy.What the deprecated class is
In the sources of
idea/242.20224.300andidea/263.7307.200, the same in both:EnterBetweenBracesHandleronly overridesisApplicableofEnterBetweenBracesFinalHandler, to use the defaultEnterBetweenBracesDelegateinstead of the one of the file's language.EnterBetweenBracesFinalHandler, which isn't deprecated, with the idEnterBetweenBracesHandler. The deprecated class isn't registered.EnterBetweenBracesDelegateof their own in 2024.2, and JavaScript too in 2026.3: no TextMate, plain text oranyone.The replacement that the deprecation names, an
EnterBetweenBracesDelegateof a language, can't do what the workaround does: it rewrites the braces and their indent once the Enter is done, inpostProcessEnter, for files of any language that a language server serves.The change
EnterHandlerDelegateAdapter, which isn't deprecated on 2024.2 to 2026.3.EnterBetweenBracesFinalHandlerfirst, as the deprecated class did. Their languages have no delegate, so the default one decides, as before. For a TextMate file it splits nothing, since its braces are in the same PSI element: the fix ispostProcessEnter's, which doesn't change.Continue.It doesn't extend
EnterBetweenBracesFinalHandler, whose javadoc asks not to. 2026.3 also makes the static helpers that the deprecated class uses@ApiStatus.Internal.Tests
New
EnterBetweenBracesOrderTest, on a JSON file, which has no language server in these tests, and whose braces are elements of their own:testAHandlerBeforeTheEnterBetweenBracesSeesTheBracesOfAFileWithoutALanguageServerAsTheyWere: an Enter handler orderedbefore EnterBetweenBracesHandlerrecords the document it seesexpected:<[{}]> but was:<[{\n}]>, LSP4IJ had split the braces alreadytestTheEnterBetweenTheBracesOfAFileWithoutALanguageServerSplitsThemTypeScriptEditorImprovementsTestandTypeScriptCustomLanguageServerEditorImprovementsTesttest the fix itself, with it enabled and disabled, and pass unchanged.Headless, with the counts from the JUnit XMLs:
features.formatting, with the first version of the new test1EnterBetweenBracesOrderTest,TypeScriptEditorImprovementsTest,TypeScriptCustomLanguageServerEditorImprovementsTestNot covered
Footnotes
The first version of
EnterBetweenBracesOrderTestused a plain text file, whose braces are in one element, which no Enter splits, and a TextMate file, whose braces the platform doesn't split either. It failed with the old handler and the new one alike, and was rewritten. ↩