Skip to content

Wrapping kicks in even when maxLineLength is not exceeded #670

@alexeychikk

Description

@alexeychikk

Describe the bug

Wrapping for functionSignature (or maybe it's anonFunctionSignature) kicks in although the line is exactly 80 characters long. However onePerLine rule is not applied as specified in hxformat.json. I suggest that somewhere in your code there is inconsistency in the way you compare line lengths, e.g. the default behavior might be >= maxLineLength (that's why onePerLine is not applied) while the behavior for exceedsMaxLineLength is > maxLineLength.

Input file

function sleep(ms: Int = 0): Promise<Never> {
  return new Promise((resolve, reject) -> Timer.delay(() -> resolve(null), ms));
  // the line above is exactly 80 characters long
}

Broken output

function sleep(ms: Int = 0): Promise<Never> {
  return new Promise((resolve,
    reject) -> Timer.delay(() -> resolve(null), ms));
}

Expected output

function sleep(ms: Int = 0): Promise<Never> {
  return new Promise((resolve, reject) -> Timer.delay(() -> resolve(null), ms));
}

Optional: hxformat.json

{
	"indentation": {
		"character": "  "
	},
	"wrapping": {
		"maxLineLength": 80,
		"callParameter": {
			"defaultWrap": "fillLine",
			"rules": [
				{
					"type": "onePerLine",
					"conditions": [{ "cond": "exceedsMaxLineLength" }]
				}
			]
		},
		"functionSignature": {
			"defaultWrap": "fillLine",
			"rules": [
				{
					"type": "onePerLine",
					"conditions": [{ "cond": "exceedsMaxLineLength" }]
				}
			]
		},
		"anonFunctionSignature": {
			"defaultWrap": "fillLine",
			"rules": [
				{
					"type": "onePerLine",
					"conditions": [{ "cond": "exceedsMaxLineLength" }]
				}
			]
		}
	},
	"whitespace": {
		"typeHintColonPolicy": "after",
		"bracesConfig": {
			"anonTypeBraces": {
				"openingPolicy": "around",
				"closingPolicy": "before"
			},
			"objectLiteralBraces": {
				"openingPolicy": "around",
				"closingPolicy": "before"
			},
			"typedefBraces": {
				"openingPolicy": "around",
				"closingPolicy": "before"
			}
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions