Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a soft wrap option to handle Lines and ShowLineNumbers behavior #163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Hazegard
Copy link

@Hazegard Hazegard commented Dec 14, 2024

This PR introduces a SoftWrap option that adjusts the behavior of the Lines and ShowLineNumbers options when used with the Wrap option.

  • Lines:
    Currently, when both Lines and Wrap options are used, the line count is computed after wrapping occurs. This can lead to discrepancies where wrapped lines count as multiple lines, causing the final output to exclude some original input lines.
    With the new SoftWrap option, wrapped lines will count as a single line, ensuring that all lines specified in the Lines option are correctly included.

  • ShowLineNumbers:
    When SoftWrap is enabled, line numbers are not added to wrapped lines. This preserves the original line numbering, ensuring consistency with the input file.

Here is an example showing the behavior when softwrap is used and when softwrap is not used :

Without SoftWrap With SoftWrap
freeze -w 80 --lines 17,50 --show-line-numbers config.go freeze --soft-wrap -w 80 --lines 17,50 --show-line-numbers config.go
image image

@Hazegard Hazegard force-pushed the soft_wrap branch 2 times, most recently from af350e3 to b428d1c Compare December 15, 2024 15:58
This commit introduces a `SoftWrap` option that adjusts the behavior
of the `Lines` option and `ShowLineNumbers` when used with the `Wrap` option.

- `Lines`:
Currently, when both `Lines` and `Wrap` options are used, the line count
is computed after wrapping occurs. This can lead to discrepancies where
wrapped lines count as multiple lines, causing the final output to exclude
some original input lines.
With the new `SoftWrap` option, wrapped lines will count as a single line,
ensuring that all lines specified in the `Lines` option are correctly included.

- `ShowLineNumbers`:
When `SoftWrap` is enabled, line numbers are not added to wrapped lines.
This preserves the original line numbering, ensuring consistency with the input file.
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.

1 participant