From cd62d0f5e899df61dc2772fc4f5513acb64df8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Mon, 16 Sep 2024 14:23:15 +0200 Subject: [PATCH] git-grep: add comments on highlighting support --- modules/git/grep.go | 4 ++++ 1 file changed, 4 insertions(+) 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