[gnome-builder] grep: Make filename matching regex include all possible characters

commit 55bd7f9867967ee366f574da5e3e41a5c8ba69a0
Author: vanadiae <vanadiae35 gmail com>
Date:   Mon Dec 20 16:44:38 2021 +0100

    grep: Make filename matching regex include all possible characters
    Currently when doing a search that includes files that contain @, like
    po/ca valencia po, the filename extracted from the grep output with the regex
    is incomplete as it instead thinks the filename is valencia.po. So when accessing
    the line location, it opens an empty file because obviously valencia.po doesn't
    exist, whereas po/ca valencia po does exist.
    Anyway, the regex that extracts the file name, line number and line content is
    too restrictive in what in detects as being valid for a filename. It only accepts
    alphanumerical characters and characters contained in [-_+.]. As such, there's not
    much reason to restrict so much the set of allowed characters for a filename, so
    it's better to allow all of them except the colon (as that's the field separator
    between filename and line number).

 src/plugins/grep/gbp-grep-model.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/grep/gbp-grep-model.c b/src/plugins/grep/gbp-grep-model.c
index 575e2346f..b26bafe68 100644
--- a/src/plugins/grep/gbp-grep-model.c
+++ b/src/plugins/grep/gbp-grep-model.c
@@ -366,7 +366,7 @@ gbp_grep_model_class_init (GbpGrepModelClass *klass)
   g_object_class_install_properties (object_class, N_PROPS, properties);
-  line_regex = g_regex_new ("([a-zA-Z0-9\\+\\-\\.\\/_]+):(\\d+):(.*)", 0, 0, NULL);
+  line_regex = g_regex_new ("([^:]+):(\\d+):(.*)", 0, 0, NULL);
   g_assert (line_regex != NULL);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]