dprint / dprint-intellij

A dprint plugin for Intellij.
https://plugins.jetbrains.com/plugin/18192-dprint
MIT License
12 stars 2 forks source link

Fixed a bunch of issues with the new external formatting service. #18

Closed ryan-rushton closed 2 years ago

ryan-rushton commented 2 years ago

Overview

This fixes a few issues introduced by the new external formatting service implementation that hooks into the standard intellij formatting commands. I have done the following

  1. Put a synchronization lock around the code blocks that call the editor service. Now we are calling it from a new places we need to ensure that it doesn't get called in asynchronously with subsequent calls interrupting the communication process.
  2. Made a bunch of the noisy logging debug
  3. Perform no-op's when range formatting is requested. Without this IntelliJ reverts back to default formatting and we get differences in the output of whole file vs ranged.
  4. Ensured that the file we are formatting is a virtual file. IntelliJ will send text to the format when it doesn't actually exist in a file yet, this happens when refactoring code, automatically generating methods, ect.
ryan-rushton commented 2 years ago

Just waiting for confirmation this is good from a colleague @dsherret.

ryan-rushton commented 2 years ago

@dsherret I was using this Friday and it was all working fine for me. I haven't heard back from others so I am happy to push this one out as a release.