Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

"Replace All - Within Current Selection" only replaces a single match #1010

Closed
WiliTest opened this issue Apr 3, 2018 · 9 comments · Fixed by #1088
Closed

"Replace All - Within Current Selection" only replaces a single match #1010

WiliTest opened this issue Apr 3, 2018 · 9 comments · Fixed by #1088

Comments

@WiliTest
Copy link

WiliTest commented Apr 3, 2018

Edit by @rsese

Reproduced on macOS 10.12.6 with 1.39.0-nightly11:

  1. create a new file
  2. Enter:
hello
hello
  1. Select all the text
  2. Find And Replace: Show
  3. Enable Only in Selection
  4. Set search text to hello and replace text to bye
  5. Click Find All
  6. Click Replace All

2 results are reported after step 7 and then after step 8, only the second hello is replaced:

in-selection


Prerequisites

Description

"replace all" only replace a single one whithin selection

Steps to Reproduce

  1. in styles.less select this text: syntax--punctuation syntax--section syntax--property-list
  2. trigger the find and replace
  3. replace all within the current selection --syntax by .

Expected behavior: [What you expect to happen]

all --syntax should be replaced by .

Actual behavior: [What actually happens]
only one --syntax is replaced

Reproduces how often: [What percentage of the time does it reproduce?]
5 times

Versions

windows 10
1.25.0
(by the way atom --version don't output anything in the cmd. And apm --version throw an error)
cmd_2018-04-03_23-18-04

Additional Information

screenshot:
2018-04-03_22-58-57

@WiliTest WiliTest changed the title "replace all" only replace a single one "Replace All - Within Current Selection " only replace a single one Apr 4, 2018
@WiliTest WiliTest changed the title "Replace All - Within Current Selection " only replace a single one "Replace All - Within Current Selection" only replace a single one Apr 4, 2018
@philgyford
Copy link

This has been driving me nuts too. Finding within a selection has been buggy for years (e.g. #298). Here's an example of a way in which this works sometimes, and not others.

Working

  1. Select text
  2. Hit cmd-F
  3. Click 'Only in Selection' button
  4. Enter find/replace text
  5. Click 'Replace All' button.

Result: All matches in selection are replaced

works

Not Working

(Note, the steps are identical except steps 3 and 4 are reversed.)

  1. Select text
  2. Hit cmd-F
  3. Enter find/replace text
  4. Click 'Only in Selection' button
  5. Click 'Replace All' button.

Result: Only the final match (in the order the selection was made) is replaced.

fail

@philgyford
Copy link

Another example, and one that is sporadic and hard to reproduce reliably...

  1. With Regex and Within Current Selection already 'on'...
  2. Select text
  3. Hit cmd-F
  4. The selected area shrinks to only include the first match, and "1 result" is listed.
  5. Click 'Replace All'
  6. All of the matches in the originally-selected text are replaced, not just that first one.

sort of

So, the correct result, in the end, but an odd intermediate stage.

However, sometimes it only replaces that first match, and not the others within the selection.

And, sometimes, the selected area is displayed correctly.

@philgyford
Copy link

One more example of a slightly different oddness...

  1. Select text containing what will be 2 matches (the find and replace fields are already populated in the search panel).
  2. Hit cmd-F
  3. '4 results' is displayed, as expected.
  4. Click 'Within Current Selection' button.
  5. '2 results' is displayed, as expected.
  6. Unclick 'Within Current Selection' button.
  7. '4 results' is displayed, as expected.
  8. Click 'Within Current Selection' button again.
  9. '1 result' is displayed, and the selection has been reduced to that single matching result; the original selection has been lost.

2018-05-14 11 35 38

@alisonketz
Copy link

I am having this exact same problem and it is driving me nuts. I write in R, and was hoping to use atom instead of R-studio (hate) or sublime. Please fix this! It's a deal-breaker and pretty appalling for a text editor. This is the point of having a text editor! Ubuntu 16.04

@Servinjesus1
Copy link

Can confirm this is still an issue on 1.34.0 Mac.

Workaround: While searching, Atom will highlight cases automatically within your selection. While not as visibly noticeable as hitting Find All and getting the selection set, you can still use this to verify your replacement set. Granted this only works for 3+ character strings, but at least you can still use Replace All with some modicum of comfort...

@gnthackray1978

This comment has been minimized.

@ZosoDerGoldene

This comment has been minimized.

@Cloudixx

This comment has been minimized.

@rsese
Copy link

rsese commented May 22, 2019

Reproduced on macOS 10.12.6 with 1.39.0-nightly11:

  1. create a new file
  2. Enter:
hello
hello
  1. Select all the text
  2. Find And Replace: Show
  3. Enable Only in Selection
  4. Set search text to hello and replace text to bye
  5. Click Find All
  6. Click Replace All

2 results are reported after step 7 and then after step 8, only the second hello is replaced:

in-selection

@rsese rsese added the triaged label May 22, 2019
@rsese rsese changed the title "Replace All - Within Current Selection" only replace a single one "Replace All - Within Current Selection" only replaces a single match May 22, 2019
@nathansobo nathansobo self-assigned this Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants