notepad-plus-plus / notepad-plus-plus/notepad-plus-plus

Multi-line regular expression where no match exist for pattern part after long catch-all matches from start of match until end of file

Open
#8,545 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
29.4k
Forks
5.4k
PR merge metrics
No merged PRs in 30d

Description

Description of the Issue

Doing a find using a regular expression with ". matches newline" enabled using a regular expression similar to:

(Start:).*^(\1 End pattern) 

where a match for (Start:) exists, but no match for ^(\1 End pattern) over a large file will match from (Start:) to the end of the file.

Steps to Reproduce the Issue
  1. Create a new text file with the following content:
    On a text file with contents similar to:
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (P1)
1>FastUpToDate: ...
1>FastUpToDate: Project is up to date. (P1)
1>FastUpToDate: Up to date check completed in 10 ms (P2)
2>FastUpToDate: Adding UpToDateCheckBuilt outputs: (P2)
2>FastUpToDate: ...
2>FastUpToDate: Input marker is newer than output marker, not up to date. (P2)
2>FastUpToDate: Up to date check completed in 49,1 ms (P2)
3>FastUpToDate: Adding UpToDateCheckBuilt outputs: (P3)
3>FastUpToDate: ...
3>FastUpToDate: Project is up to date. (P3)
3>FastUpToDate: Up to date check completed in 14 ms (P3)

(or use npp-regex-bug.txt)

  1. Duplicate the line 2>FastUpToDate: ... so that it appears at least 2093 times in the file.
  2. Go to the start of the file and search for (\d+>FastUpToDate:).*^(\1 Project is up to date\.) using the "Regular expressions" and ". matches newline" options.
  3. Click "find next"
Expected Behavior

First hit is the lines

1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (P1)
1>FastUpToDate: ...
1>FastUpToDate: Project is up to date. 

Second hit is the lines

3>FastUpToDate: Adding UpToDateCheckBuilt outputs: (P3)
3>FastUpToDate: ...
3>FastUpToDate: Project is up to date. 
Actual Behavior

First hit were the lines

1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (P1)
1>FastUpToDate: ...
1>FastUpToDate: Project is up to date. 

Second hit was from the line 2>FastUpToDate: Adding UpToDateCheckBuilt outputs: (P2) to the end of the file.

Debug Information

Notepad++ v7.8.7 (64-bit)
Build time : Jun 5 2020 - 02:38:56
Path : C:\Program Files\Notepad++\notepad++.exe
Admin mode : OFF
Local Conf mode : OFF
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 1803
OS Build : 17134.1553
Current ANSI codepage : 1252
Plugins : DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll XMLTools.dll

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in Notepad++ using the attached npp-regex-bug.txt file, the provided regular expression, and the “. matches newline” option. Start with Find Next and verify that the second match incorrectly runs to the end of the file; done means the expected first and second matches are returned instead.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.