Skip to content

OSX - Colon replacement incorrectly reads closure curly braces as a struct #165

@jclausen

Description

@jclausen

With the following settings:

	"struct.separator": " : ",
	"struct.padding": true,
	"struct.empty_padding": false,
	"struct.multiline.leading_comma": false,
	"struct.multiline.leading_comma.padding": true,
	"struct.multiline.element_count": 2,
	"struct.multiline.min_length": 60,

The following block of code:

hyper
	.fake( {
		"https://mydomain.com/auth" : (
			newFakeResponse,
			req
		) => {
			var body = req.getBody();
			if ( body.User != "valid_user" || body.Secret != "valid_secret" ) {
				return newFakeResponse( 401, "Unauthorized" );
			}

			return newFakeResponse(
				200,
				"Created",
				serializeJSON( {
					"token"      : "valid_token",
					"expiration" : dateAdd( "d", 1, now() )
				} )
			);
		},
		...
	} );

ends up being formatted ( note the change of the var body = req.getBody(); to var body : req.getBody(); ):

hyper
	.fake(
		{
			"https://mydomain.com/auth" : (
				newFakeResponse,
				req
			) => {
			var body : req.getBody();
			if ( body.User ! : "valid_user" || body.Secret != "valid_secret" ) {
				return newFakeResponse( 401,
			"Unauthorized" );
		}

		returnnewFakeResponse(
			200,
			"Created",
			serializeJSON( {
				"token"      : "valid_token",
				"expiration" : dateAdd( "d", 1, now() )
			} )
		);
		},

		...
		});

This seems to happen on OSX but not on Linux. I have not tested on Windows. Once the replacement of = to the : is made, then all of the formatting afterwards is also messed up. This happens on all versions from 0.16.x and up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions