-
Notifications
You must be signed in to change notification settings - Fork 219
Matching whole word that ends with a period causes odd results #1028
Comments
Same issue with searches starting with periods. |
This issue still exists with Atom 1.28.2 |
Thanks for the report! I think (I'm not very experienced with regexes) what you're describing is expected? Whole word search looks like it uses regex word boundaries: find-and-replace/lib/find-options.coffee Line 71 in fdbf81f
And I think the issue is that the dot isn't considered an alphanumeric character? This StackOverflow post talks about a similar issue and this regex check seems to confirm: https://regex101.com/r/s9ySh9/1 I also checked in Sublime and it behaves the same as well where only the first line Does that make sense @cdusold or am I mis-understanding? |
@rsese You are misunderstanding a little, but this explains a little too.
into the file, and search This is on Ubuntu 16.04.5 LTS this time. As soon as I have the chance, I'll double check Windows 10 and get a screen cap of the behavior. Adding spaces before any of the |
Found the issue with the weird marker changes when pressing space, will patch soon. Edit: It was more complicated than I thought. I believe (currently) the issue is that only the text in the range of two existing matches surrounding a change is looked at, and so the word break fails because it was at the end of the range, so the word character to the right is not detected. I.e.,
This will take some more effort to fix. The actual searching gets down into the native I haven't looked at the replace issue yet, but it's definitely related to this issue. Lookahead also fails to replace. |
Prerequisites
Description
Whole Word find functionality does not match Whole Word replace functionality if the search starts with a period or ends with a period. That is to say, it will match strings in find, but refuse to replace them. This seems to indicate a disconnect between the two functions, and lead me to not realizing I accidentally left Whole Word on as find was matching strings it should not have in theory.
Steps to Reproduce
atom --safe
a.b
a.
a.
a\.
Expected behavior: Honestly, not entirely sure, but at least it should be consistent. substring 'a.' of 'a.b' isn't a full word, and the line where 'a.' is all that's there doesn't get picked up at all, and if anything that looks more like a whole word. I'm pretty sure a whole word search of 'a.' shouldn't be able to match anything as it isn't a whole word, but multi-word searches can use whole word just fine.
At the very least, I expect a matched string to be replaced at step 11.
Actual behavior: The substring 'a.' of 'a.b' is matched, but the next line isn't. Adding or removing whitespace of any kind (tab, space, and newline) before 'a.b' toggles whether it matches or not. And hitting Replace occasionally makes it stop matching in the find results, but I'm not sure if there's a pattern to it.
Reproduces how often: Every time I've tried.
Versions
Atom : 1.27.2
Electron: 1.7.15
Chrome : 58.0.3029.110
Node : 7.9.0
apm 1.19.0
npm 3.10.10
node 6.9.5 x64
atom 1.27.2
python 2.7.12
git 2.13.0.windows
visual studio 2015
Windows 10 Pro
Version 1709
OS Build 16299.251
Additional Information
A multi-word "Whole Word" search ending in a period doesn't ever match, but one with a space afterwards does (e.g.
longer test.
vs.longer test.
matching against "This is a longer test. Test.").I found this by trying to find and replace
self.
from a method I turned into a function in a python script. I accidentally had Whole Word on from an earlier replacement. It matched all of them, but when I hit "Replace," nothing happened. So the logic for finding seems to be different than the logic for replacing while Whole Word is on.The text was updated successfully, but these errors were encountered: