Skip to content

add support for continuous hard wrap #2274

Open
@vlmutolo

Description

@vlmutolo

Continuous hard wrap

#2128 deals with hard-wrapping selected text, but ideally we'd have a way to hard-wrap as the user types. This makes for a much better experience when editing files with comments, hard-wrapped plaintext documentation, etc. All the same use cases we listed for the reflow command.

In terms of implementation, I think we could actually just basically do "reflow" on every key press (while in input mode with this feature enabled). It probably shouldn't be exactly the same, since the reflow command optimizes the paragraph globally to produce consistent line lengths close to the maximum, and it would be kind of a weird experience to have the lines reflow back and forth while you're typing. So we'd want to use the "greedy" mode from textwrap for the wrapping instead of their "optimal" mode.

In terms of performance, we'd only be reflowing one paragraph at a time, and that really shouldn't be too expensive. I'd propose as a first cut doing reflow (almost) exactly as we do it now, but on every key press. Then, as I mentioned in a comment on 136, if we wanted more performance we could try to send a patch upstream to the textwrap crate for an "incremental" wrap command that would work off of a delta and produce maybe an iterator of Cow<str> and regions that were changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-helix-termArea: Helix term improvementsC-enhancementCategory: Improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions