prettier-plugin-apex icon indicating copy to clipboard operation
prettier-plugin-apex copied to clipboard

Selective Formatting not working

Open amitkumarj1979 opened this issue 5 years ago • 4 comments

# Prettier options (if any):
Default

**Input:**
cls file - Selected Text

```apex
// code snippet
```errorList.addAll(validateField(contact.FirstName, objectName, 'First Name', 0));


**Actual output:**
```errorList.addAll(validateField(contact.FirstName, objectName, 'First Name', 0));

```apex
// code snippet

Expected output:

            validateField(contact.FirstName, objectName, 'First Name', 0)
        );


```apex
// code snippet

Additional information (please fill this out):

  • OS: [e.g. Windows/OS X/Ubuntu]
  • Version: [e.g. 1.0.0] mac 10.14.6

amitkumarj1979 avatar Feb 19 '20 17:02 amitkumarj1979

Hi, thank you for submitting your issue. Currently there are some issues with formatting in your post, so I can't really tell what is not working right. Could you reformat it, or describe it in some way?

dangmai avatar Feb 19 '20 17:02 dangmai

Sorry, the issue is if I try to Format the complete file the formatting works, But it does not work with Selective text. Example : I select a block of code

errorList.addAll(validateField(contact.FirstName, objectName, 'First Name', 0));

Nothing happens and I get an error in the VS Code status bar as Extension Prettier cannot format the file.

Does this help ?

amitkumarj1979 avatar Feb 19 '20 17:02 amitkumarj1979

Oh I see, thank you for the explanation, that helps a lot. I think this is actually a feature request for Range Formatting support by this plugin. I will take a look at this soon.

dangmai avatar Feb 19 '20 17:02 dangmai

I have looked into this, and unfortunately Prettier does not allow its plugins to do this at the moment. I have opened an issue upstream here, and when that is resolved I will make sure prettier-plugin-apex supports it.

dangmai avatar Feb 19 '20 20:02 dangmai