atom / find-and-replace

Find and replace in a single buffer and in the project
MIT License
242 stars 196 forks source link

Searches using regular expressions and look ahead/behind do not update correctly #1148

Open torik42 opened 3 years ago

torik42 commented 3 years ago

Prerequisites

Description

The results of find-and-replace usually update when the file is changed. However, this does not work as expected when using regular expressions with look-ahead/-behind.

Steps to Reproduce

  1. Open a file.
  2. Add some text, e.g. bdb ada adb ada adb.
  3. Open find and replace and search using regex with look ahead and look behind, e.g. (?<=a)d(?=a) to find the character d surrounded by as.
  4. Change parts of the string which contain the match, in this example remove some of the ds or change the surrounding such that it is not matched any more.

Expected behavior:

During editing, the matches should update automatically and correctly.

Actual behavior:

During editing, the matches do not update correctly. Here is an example:

https://user-images.githubusercontent.com/77811180/111620703-5baa1380-87e7-11eb-9a0f-a9f3a2277d72.mov

Reproduces how often:

Always, but with different behaviour.

Versions

macOS Catalina 10.15.7

Atom : 1.55.0 Electron: 6.1.12 Chrome : 76.0.3809.146 Node : 12.4.0

apm 2.5.2 npm 6.14.8 node 12.4.0 x64 atom 1.55.0 python 3.8.6 git 2.24.3

Additional Information

Even, if one clicks search again, it does not update correctly. But if one changes the search term, e.g. remove the last ) and add it back, then it finds the occurrences correctly again.

strixy commented 2 years ago

I am experiencing this issue with v 1.58 on Linux. Find is index: \N Replace is index: n language used is JS It's weird. It finds what I expect it to find, but makes no changes. Weirder still, hitting undo will walk back through the items it should have changed, but didn't change, showing no change was undone.

Audiofrank commented 2 years ago

I am experiencing this issue with v 1.58.0 x64 on Linux (Ubuntu), in safe mode too. Find is: \b(\.)\b Replace is: empty field Language is a text-File (.a51), Assembler-File with Tabs and comments after ; First it finds all "." correctly, but after editing, for example, by adding the same letter in an empty line lets say 10 times, the search result changes. Some of the former results are gone or changing while adding more letters. Deleting the added letters by the backspace-key completely, so I have the state where I started from, shows a different Find-result. I can only get the correct search result again by switching the RegExp-Button off and on or by changing the text in the Find-field in that way deleting something and fill it in again.