Bug 462711 - Multiline concat strings are formatted back on a single line
Summary: Multiline concat strings are formatted back on a single line
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 454865
Blocks:
  Show dependency tree
 
Reported: 2015-03-20 14:25 EDT by Rik Bartolini CLA
Modified: 2020-05-14 10:15 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rik Bartolini CLA 2015-03-20 14:25:35 EDT
Let's say I have something like
$stm = 'CREATE TABLE queue(' . 
   'id INTEGER PRIMARY KEY,' . 
   'rec TEXT NOT NULL,' .
   'subject TEXT NOT NULL,' .
   'body TEXT NOT NULL,' .
   'headers TEXT NOT NULL);';

Pressing CTRL+SHIF+F results in a single line string.
I hope this is a bug and not by design or I get scared! :-)

Furthermore the formatter doesn't use the colum limit as the HTML formatter does, so I have to scroll horizontally... and that's not good at all.

I've found only one unacceptable workaround: @formatter:off/on on every multiline string.


Please, add an option such as "Get your hands off my strings!!!" :-)
or as suggested by the more professional friend Dawid Pakula on the Eclipse forum:
1. Initializer justification
2. Preserve new lines after "." operator

Anyway the sense must be "Don't touch my strings!" :-)

See ya!
Rik
Comment 1 Rik Bartolini CLA 2015-03-20 14:37:23 EDT
PS: I set this report as normal bug, but actually to me it's so important that I was thinking to get back to Indigo or jump on Juno (PDT 3.1.2 was the last one without this problem).
Comment 2 KB Benton CLA 2015-06-28 23:25:22 EDT
If I could vote for this bug, I would. @formatter:off/on is a workaround as you noted, but it's also rather kludgy.
Comment 3 KB Benton CLA 2015-06-28 23:26:38 EDT
Personally, I prefer this style of formatting:

            //@formatter:off
            return "<html>\n"
                  . "<head>\n"
                  . '  <title>' . $this->getPageTitle() . "</title>\n"
                  . $this->getHead()
                  . $this->getStyles()
                  . "</head>\n"
                  . "<body>\n"
                  . $this->getTop()
                  . $this->getBody()
                  . $this->getBottom()
                  . "</body>\n"
                  . "</html>\n"
                  ;
            //@formatter:on

Either way, I agree - get your hands off my multi-line strings.
Comment 4 KB Benton CLA 2015-06-28 23:29:06 EDT
Never mind - I did vote for this bug. :-)
Comment 5 KB Benton CLA 2015-06-28 23:34:19 EDT
Verified behavior in Eclipse Mars
Comment 6 Rik Bartolini CLA 2015-08-17 10:47:55 EDT
Mitigation factors/ partial workaround.

Windows->preferences->php->code style->formatter->
edit (a custom style)->line wrapping->expressions->binary espressions

OK, here "Do not wrap" should do nothing instead of bringing anything on a single line, BUT at least, 
- "Wrap only when necessary" usea the limits (e.g. width 80)
and
- "Every element on a new line" formats just the way I do manually.

Obviously I can have a mix like
$stm = 'CREATE TABLE queue(' . 
   'id INTEGER PRIMARY KEY,' . 
   'rec TEXT NOT NULL,' .
   'subject TEXT NOT NULL,' .
   'body TEXT NOT NULL,' .
   'headers TEXT NOT NULL);';

and

$a='aaaaaaa'.'bbbbbbbb';

but at least I don't find myself with lines of 2km to scroll horizontally.

Can't wait to have back the old way when I could have my strings concatenation untouched.

By the way I expect "Do not wrap" to actually do NOTHING instead of unwrapping my style. Otherwise you should call it "Unwrap" or "bring all on a single line".
Comment 7 Nobody - feel free to take it CLA 2015-10-09 15:27:06 EDT
I also want this. Ticket #454865 requests a solution to the more general problem of re-wrapping (the example given is array initializers).