Skip to content

Summarize search hits for same file

Description

When multiple search hits occur in the same file, they are presented the same as different files. I find that confusing.

See for example this search: https://gitlab.com/search?group_id=&project_id=13083&repository_ref=&scope=blobs&search=add

For CHANGELOG.md the header appears many times:

changelog-search-hits

Design

Currently there is no space between code blob results.

.blob-result {
    margin-top: 16px;
}

will result in: image

Currently there is always a white empty line shown at the top of a search result not beginning at line 1: image

We should get rid of that!

All results from the same file will need to be merged into 1

Apart from that we should give feedback on how many search hits are in this file, that is truncated to search hits from 3 lines minimum to 6 lines maximum (note: it could be possible to show all lines highlighted as each of the 6 lines could show the search keyword). We could up the maximum for 9 lines of code.. always showing the top 3 hits of the X amount.

It would result in this:

image

For multiple results it looks like (with the 3 dot/ellipses white line between those results):

image

Don't mind the highlighting! It will be part of #24475 (moved)

cc @awhildy