Skip to content

--trim runs after -M/--max-columns #2458

@BurntSushi

Description

@BurntSushi

See the discussion below. It seems to me like --trim should run before applying the max column length.

I say this without re-contextualizing myself with the code. There may be a reason for the current behavior that I'm forgetting.

Discussed in #2456

Originally posted by misaki-web March 15, 2023
Is there a way to make ripgrep apply the --trim flag before reducing the line length with --max-columns-preview -M?

Here's an example of the current result (the string starts with 5 spaces):

$ echo "     0123456789abcdefghijklmnopqrstuvwxyz" | rg --trim --max-columns-preview -M 8 abc
012 [... 1 more match]

ripgrep reduces the line length, then it trims it. I expected the opposite, like this:

$ echo "     0123456789abcdefghijklmnopqrstuvwxyz" | rg --trim --max-columns-preview -M 8 abc
01234567 [... 1 more match]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug.rollupA PR that has been merged with many others in a rollup.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions