Skip to content
  • Christian Hergert's avatar
    grep: add plugin to grep through project tree · 239fdc0c
    Christian Hergert authored
    This plugin provides a grep backend that can optionally use git-grep when
    the current project is using Git.
    
    You can search for files from the project-tree by selecting "Find in Files".
    That will limit the search results to the directory that has been selected.
    
    If the selected node is a File (instead of a directory), then only results
    from that file will be shown.
    
    You can search using regular expressions supported by the particular grep
    implementation. We don't currently guarantee options here (or validate them
    for correctness). Some effort could be done here using GRegex in the future.
    
    As we already have support for performing edits across a number of files in
    the background, the grep plugin allows you to select matches and replace them
    with new text. In the future we could extend this to try to preserve casing
    of the replacement.
    
    To avoid lots of small strings and numerous copies of them, a custom
    GtkTreeModel was used. Instead we have a single large buffer of results that
    were obtained from grep, and keep an index to the start of each line in the
    buffer. A \0 replaces the \n that we received from grep.
    
    I expect additional work will be needed here, but this seems like a reasonable
    first attempt at the feature. Larger projects may need additional performance
    tweaks.
    239fdc0c