Skip to content

[Suggestion] Don't join string literals that are split #391

@junderw

Description

@junderw

Edit: (Related: solidity-parser/parser#32 this is required to allow hex literals to have the same formatting)

I have a 148 character long string that is hard to look at in the source code. So I've split it using multi-line and prettier-ignore

Similar to JavaScript prettier, if I write a string as 'abc' + 'def' than it tends to format things nicer than when I keep everything as one long string, the format process feels free to play around with my "chunks" and their position to make the "prettiest" format.

Currently split strings get joined.

Example:

string memory a = 'abc'
                    'def'
          'ghi';

Current Result:

string memory a = 'abcdefghi';

Suggestion:

string memory a = 'abc'
    'def'
    'ghi';

Or maybe have them be same line unless going over a certain length:

// assume including the ghi chunk would put it over the one line length limit.
string memory a = 'abcdef'
    'ghi';
// OR
string memory a = 'abc' 'def'
    'ghi';

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions