Skip to content

Unable to :clear-highlight if added :highlight ends with whitespace #1638

@dardhal

Description

@dardhal

lnav version
Compiled from current main

Describe the bug
As in the subject, if accidentally adding a :highlight for a string ending in whitespace, then :clear-highlight will be unable to remove it later on.

Definitely a very minor issue.

To Reproduce
Open any log file. Enter a string to :highlight , but introduce a space at the end. Now try to :clear-highlight choosing the string from the drop down. The drop down correctly shows the garbage blank space at the end, when you select it the right string (with the trailing whitespace) is filled in the command line, but the command returns error because the highlight does not exist.

And there is no amount of quoting I have attempted that correctly captures the string with the trailing space so that :clear-highlight really works.

Possible Fix
Alternatives would be :

  • Do nothing. This is rather a corner case, and while it may be a valid use case to highlight a string ending in a blank (to not highlight when string is part of a longer word), the alternative that seems to work is using a pattern like "string\s" instead
  • Fix at the time of entering the pattern : not allow a pattern to end in whitespace
  • Fix at the time of clearing the highlight. Probably overkill

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions