@@ -25,12 +25,10 @@ func init() {
2525 rgPath, err = exec.LookPath("rg")
2626 if err != nil {
2727 logging.Warn("Ripgrep (rg) not found in $PATH. Some features might be limited or slower.")
28− rgPath = ""
2928 }
3029 fzfPath, err = exec.LookPath("fzf")
3130 if err != nil {
3231 logging.Warn("FZF not found in $PATH. Some features might be limited or slower.")
33− fzfPath = ""
3432 }
3533}
3634
@@ -49,9 +47,21 @@ func GetRgCmd(globPattern string) *exec.Cmd {
4947 }
5048 rgArgs = append(rgArgs, "--glob", globPattern)
5149 }
52− cmd := exec.Command(rgPath, rgArgs...)
53− cmd.Dir = "."
54− return cmd
50+ return exec.Command(rgPath, rgArgs...)
51+}
52+
53+func GetRgSearchCmd(pattern, path, include string) *exec.Cmd {
54+ if rgPath == "" {
55+ return nil
56+ }
57+ // Use -n to show line numbers and include the matched line
58+ args := []string{"-n", pattern}
59+ if include != "" {
60+ args = append(args, "--glob", include)
61+ }
62+ args = append(args, path)
63+
64+ return exec.Command("rg", args...)
5565}
5666
5767type FileInfo struct {