FormattingService implementing AsyncDocumentFormattingService not invoked on mass-reformat / save action

Answered

I'm trying to figure out why my FormattingService implementing AsyncDocumentFormattingService is not invoked whenever I tried to reformat multiple files (e.g. a whole folder). Also, it isn't possible to get my files to reformat on save (my filetype isn't shown in the Setting > Tools > Action on Save option for "Reformat Code"). I have implemented my service as outlined in the documentation and for single files in works perfectly (even keeping the cursor at a reasonable position most of the time).

Is reformatting multiple files only supported when I implement the Format Model Builder? Any workaround for this?

0
4 comments

Hi,

I don't see any special conditions excluding AsyncDocumentFormattingService from the formatting action. Could you please share a minimal implementation that allows reproducing it and describe the steps to reproduce it?

0

I have created a small demo plugin based on the plugin template which you can check out here: https://github.com/sischnei/reformatIssueDemo


To reproduce the issue, start an IDE with the plugin and create 2 files in a folder ending with the ".demo" extension. Make sure the file content contains commas - e.g. like "abcd, xyz". Try reformatting the files individually should add line breaks after the commas. Now try reformatting the files by selecting their parent folder and use the Ctrl + Alt + L hotkey to start formatting. Observe, that the files are not formatted.

See also this GIF showing that reformatting individual files works, but folders doesn't:

 

0
Avatar
Rustam Vishniakov

I guess it's a platform bug. Please feel free to create a new issue here: https://youtrack.jetbrains.com 

0

Please sign in to leave a comment.