Skip to content

More nuanced find/replace highlighting #131

@LandonSchropp

Description

@LandonSchropp

Current Behavior

When finding and replacing text, there are currently two main highlight options: highlight.search and highlight.replace.

When I'm searching for text, this works pretty well:

Screen Shot 2023-05-31 at 1 16 06 AM

However, when I'm replacing text, things look a bit odd.

Screen Shot 2023-05-31 at 1 16 20 AM

The text being removed is still highlighted in the same DiffChanged neutral color, and the text being added is highlighted in DiffDelete (which is almost always red).

Expected Behavior

The current behavior for searching makes sense, and I wouldn't change it. However, when a replacement term is entered, I'd expect the new text to be highlighted in DiffAdd (usually green) and for the text being replaced to be highlighted in DiffDelete (usually red). This behaves more like a preview of what will happen when you replace the items.

In my editor, this change would look like the following:

Screen Shot 2023-05-31 at 1 21 48 AM

It's subtle, but I think it's helpful.

Needed Config

In order to accomplish this, I think you need to split the current replace option into two options. Something like this:

  highlight = {
      ui = "String",
      search = "DiffChange",
      delete = "DiffDelete"
      add = "DiffAdd"
  },

If you wanted to keep the existing option for backwards compatibility, something like this could also work:

  highlight = {
      ui = "String",
      search = "DiffChange",
      replaced = "DiffDelete"
      replace = "DiffAdd"
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions