@Marshall-Brooks, @Zack-Wallace, @PeterJones, @mkupper, @guy038 and anyone else interested:
When I coded the Search functions in my Columns++ plugin, I made an attempt to show context.
In the original implementation of Search in Columns++, it was not possible for a match to span multiple lines, because it worked only on column selections and each match had to occur within a single row. Looking at my code (it’s been awhile), it looks like I never changed the positioning code to account for the expansion to contiguous multi-line search regions… so it probably does some dumb things now which I just never noticed. I apparently made these choices:
If the (first) line containing the found text is visible on the screen, don’t scroll vertically.
If the (first) line containing the found text is not visible on the screen, scroll so that it is approximately one-quarter of the total number of lines visible on the screen past the nearest edge.
If after scrolling vertically (if required) the entire found text is visible, don’t scroll horizontally.
If it’s possible to show the entire found text while scrolled all the way to the left, scroll all the way to the left.
If the width of the found text is greater than or equal to the width of the visible area, scroll the end of the found text (the caret) to the far right edge.
If the width of the found text is less than the width of the visible area, scroll so that the margin in the direction preceding the search (left for forward searches, right for backward searches) is the lesser of five times the width of a blank in the default style and half the difference between the widths of the visible area and the found text.
The code does not consider the area blocked by the dialog.
I assume (but do not remember) that I experimented a bit to come up with that, but mostly just made it up. I didn’t feel bad about that for a new (at the time) plugin, but I don’t think it’s good enough for a proposal to change Notepad++ itself.
I’ll have to think more about what I would suggest now for an algorithm, but input from others would be very welcome.