Skip to content

Disable auto-wrapping, preserve newlines at wrap positions#10

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/turn-off-auto-wrapping
Draft

Disable auto-wrapping, preserve newlines at wrap positions#10
Copilot wants to merge 3 commits intomainfrom
copilot/turn-off-auto-wrapping

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 1, 2026

Auto-wrapping logic based on line length was causing edge case behavior issues. This changes the formatter to preserve newlines where they exist in the source at wrap positions, rather than automatically inserting them.

Changes

  • render.rs: Removed line length checking and re-rendering logic from prettyprint(). Wrap nodes now make a single pass.

  • format_node.rs + transform.rs: Added has_newline_in_source field to WrapArguments. Detects newlines at wrap positions by comparing row positions between adjacent nodes during tree transformation.

  • Wrap node rendering: Changed from should_wrap = parent_wrap.wrap_because_length || parent_wrap.wrap_because_child to should_wrap = has_newline_in_source. Newlines are now preserved from source instead of computed from line length.

Behavior Change

Before:

// Automatically wrapped at 100 chars regardless of source formatting
myClass.myFunction(arg1, arg2, arg3);  // becomes wrapped

After:

// Preserves source formatting at wrap positions
myClass.myFunction(arg1, arg2, arg3);  // stays unwrapped
myClass.myFunction(
    arg1, arg2, arg3
);  // stays wrapped

Test files updated to reflect correct formatting under new behavior (removed newlines from non-wrap positions, fixed spacing inconsistencies).

Original prompt

This section details on the original issue you should resolve

<issue_title>Auto-wrapping off by default</issue_title>
<issue_description>The logic for wrapping has proven more difficult to get the edge behaviors we have wanted.

As an intermediary solution, we should turn auto-wrapping off by default and just mark these wrap places as spots where we allow for newlines the same way we currently allow double newlines so that we will see the newlines and permit it.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 1, 2026 06:17
Co-authored-by: johnameyer <3662655+johnameyer@users.noreply.github.com>
Co-authored-by: johnameyer <3662655+johnameyer@users.noreply.github.com>
Copilot AI changed the title [WIP] Turn off auto-wrapping by default Disable auto-wrapping, preserve newlines at wrap positions Feb 1, 2026
Copilot AI requested a review from johnameyer February 1, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-wrapping off by default

2 participants