atom / find-and-replace

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

Find and replace in project doesn't work when "whole word" option is selected in certain cases #1102

Closed IanButterworth closed 4 years ago

IanButterworth commented 5 years ago

Description

With “Find in project”, and “whole word” matching selected, a search string like "foo(", with replace string "bar(" results in the search string being used as the replace string, instead if the replace string.

Steps to Reproduce

  1. Add foo(x) to your project
  2. Find in project for foo( with replace string bar(
  3. Ensure "Whole word" is selected.
  4. Click find all
  5. Click replace all

Expected behavior:

foo( is replaced by bar(

Actual behavior:

foo( is replaced by foo(

Reproduces how often:

Every time

Versions

Atom : 1.40.1 Electron: 3.1.10 Chrome : 66.0.3359.181 Node : 10.2.0

apm 2.4.3 npm 6.2.0 node 10.2.1 x64 atom 1.40.1 python 2.7.10 git 2.21.0

MacOS 10.14.8

rsese commented 4 years ago

Thanks for the report! Reproduced with 1.40.1 on macOS 10.14.6 in safe mode - wonder if it's related to the parenthesis in the find text maybe since it's a non-word character? For example, I can reproduce when searching for foo- with the content foo-x- as well.

Just noting that after step 2:

Find in project for foo( with replace string bar(

You do see results from that search so I would expect the replace to work too I think:

find-whole-word-parens

As a side note, please leave the Prerequisites section of the issue template to let us know that you've tried things like reproduction in safe mode, etc.

IanButterworth commented 4 years ago

Great, thanks @darangi