diff --git a/modules/git/grep.go b/modules/git/grep.go index 3aa1442d29..8a896bc5aa 100644 --- a/modules/git/grep.go +++ b/modules/git/grep.go @@ -85,6 +85,9 @@ func GrepSearch(ctx context.Context, repo *Repository, search string, opts GrepO "-I", "--null", "--break", "--heading", "--line-number", "--ignore-case", "--full-name") if opts.Mode == RegExpGrepMode { + // No `--column` -- regexp mode does not support highlighting in the + // current implementation as the length of the match is unknown from + // `grep` but required for highlighting. cmd.AddArguments("--perl-regexp") } else { cmd.AddArguments("--fixed-strings", "--column") @@ -161,6 +164,7 @@ func GrepSearch(ctx context.Context, repo *Repository, search string, opts GrepO if lineNum, lineCode, ok := strings.Cut(line, "\x00"); ok { lineNumInt, _ := strconv.Atoi(lineNum) res.LineNumbers = append(res.LineNumbers, lineNumInt) + // We support highlighting only when `--column` parameter is used. if lineCol, lineCode2, ok := strings.Cut(lineCode, "\x00"); ok { lineColInt, _ := strconv.Atoi(lineCol) start := lineColInt - 1