From 4f9b3c5940a95eff2d13ddf8d08db7c946140322 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 28 Dec 2020 19:38:08 +0100 Subject: [PATCH] Fixed grep command: always show filename, even when folder contains only one file --- src/grep.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/grep.cpp b/src/grep.cpp index 270e7ca..8d3401d 100644 --- a/src/grep.cpp +++ b/src/grep.cpp @@ -29,15 +29,15 @@ Grep::Grep(const boost::filesystem::path &path, const std::string &pattern, bool if(extended_regex) flags += " -E"; - auto escaped_pattern = '"' + pattern + '"'; - for(size_t i = 1; i < escaped_pattern.size() - 1; ++i) { + auto escaped_pattern = " \"" + pattern + '"'; + for(size_t i = 2; i < escaped_pattern.size() - 1; ++i) { if(escaped_pattern[i] == '"') { escaped_pattern.insert(i, "\\"); ++i; } } - std::string command = Config::get().project.grep_command + " -R " + flags + " --color=always --binary-files=without-match " + exclude + " -n " + escaped_pattern + " *"; + std::string command = Config::get().project.grep_command + " -RHn --color=always --binary-files=without-match" + flags + exclude + escaped_pattern + " *"; std::stringstream stdin_stream; Terminal::get().process(stdin_stream, output, command, project_path);