Skip to content

Matching context with new lines in the regex doesn't work #522

Description

@nowox

Inside the latest Ack2 repository I search for this:

 $ ack "current\ndirectory.*then" 
 249:Search for PATTERN in each source file in the tree from the current
 directory on down. If any files or directories are specified, then

But if I search the same with the context:

 $ ack -A2 "current\ndirectory.*then" 
 $ 

I don't see anything. This is because the way ack parse files. It does parse the file iterating lines when context is enabled and the whole file else. No exception is handled here. This is a bug.

Activity

  1. hoelzro commented on Jan 27, 2015

    @hoelzro
    Collaborator

    This is definitely a bug; both in the inconsistency in operation between two modes that should be consistent, but also in your first example. Ack is line-based (see Can I do multi-line regexes? in the FAQ), but we read the file into a single chunk sometimes for optimization purposes.

  2. hoelzro commented on Feb 2, 2015

    @hoelzro
    Collaborator

    Ok, this is fixed in dev now. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions