vim-flog icon indicating copy to clipboard operation
vim-flog copied to clipboard

Merge Horizontal Line Highlighting Color

Open rbong opened this issue 3 years ago • 0 comments

Ideal solution

Ideally, horizontal merge line highlighting would be based on the position of the previous commit.

Ex. if the previous commit fell on an orange branch, the horizontal lines in the merge visual representation would also be orange.

This would correctly show the color of the branch that any parent commits are being merged into - this is valuable information.

Current implementation

Instead of being colored based on the previous commit, right now, horizontal merge lines are colored based on the first merge character from left to right.

├─┊─╮
^ THIS IS THE FIRST MERGE CHARACTER - HORIZONTAL LINES PAST THIS WILL BE COLORED BASED ON THIS BRANCH COLOR

This will not always be the previous commit.

This will also not be the oldest branch, or the newest branch. Branches are placed arbitrarily based on where there is room.

The result is that horizontal merge lines are colored based on some branch involved in the merge.

This is not ideal because it shows arbitrary information on the merge line. However, this information is sometimes helpful or can be used to help visually parse the branch structure, as long as you are aware of the limitations of this method.

Ideal implementation and limitations

We could, theoretically, implement the ideal solution this way.

  V COMMIT CHARACTER - START A SYNTAX REGION THAT SAVES THE COLOR OF THE BRANCH
│ • 
├─┤ < COLOR HORIZONTAL MERGE LINES ON THIS BRANCH ACCORDING TO REGION
• │ 
^ ANOTHER COMMIT CHARACTER - LOOK AHEAD AND END THE REGION AT THE BEGINNING OF THE LINE

This works - but currently, for even fairly short multi-line commits, Vim has trouble keeping track of the current region and everything ends up being drawn white.

Non-solutions

  • Manually setting the highlight color of merge lines is non-performant.
  • I would prefer not to start injecting hidden characters into the output.

Call for help

If anyone is able to implement the region-based, ideal situation without losing the color over multiple lines, help is appreciated.

rbong avatar Jan 26 '23 21:01 rbong