-
Notifications
You must be signed in to change notification settings - Fork 197
Can't search across lines with .* regex #303
Comments
if you try to do someting like
on the current buffer, it actually crashes (at least if the content is more than a couple lines long) Ubuntu 14.04 |
Ubuntu 14.04 crash still exists. |
It still crashes.
|
To be honest, I don't think that crash is easily fixable. Try running that regex through Regular expression engines are extremely slow to begin with, and V8's Irregexp engine is one of the few that isn't atrociously slow. (It's faster than most POSIX-based regex implementations, and it's faster than Perl's highly optimized, highly flexible one.) I would say one way, probably the best way, to curb the crashes is to instate a delay since the last character is added before the regex is finally executed, even as little as 200 milliseconds. I couldn't tell you how many times I've had Atom crash in the middle of me typing out a regex, simply because the incomplete one happened to match a third of the code. The other thing is that most editors don't regular expressions as they're typed - they run via a dialog or similar. Atom is rather unique in this problem. |
I don’t know if this is worth it’s own issue, but the general problem of not being able to do a multiline search without converting your search to a regular expression is a painful one. It seems like the need to use “replace in project” to modify every instance of a multiline chunk of code in a project is the kind of thing that comes up frequently enough that it would be great if the editor could handle it. There have been a few times that I just wanted to paste in a code chunk to the find field and a different one in the replace field. |
@burabure If you delete the asterisk inside the parentheses, you'll get the same matches without the crash (
|
This bug is really bad, I typed in Edit: Looks like it's working now after restarting Atom a few times, not sure what changed. |
@dbolton |
Should there be a |
VSCode and Atom are two different projects, so both issues should remain open. |
No news after three years? :-) |
@isiahmeadows As for the multiline option, since it doesn't let you search across multiple lines, I think with what I found above, that seems to basically make multiline an explicit option. |
@steviesama Good point. Maybe better to add an option to, short-term, transform |
And maybe make that option " |
What's the status on this? |
I'm not aware of any attempts to fix this issue, however we would be interested in reviewing PRs addressing this issue that don't regress in terms of performance. The current library we use for searching files is atom/scandal, where I believe files were intentionally broken up into chunks to improve search performance. |
Found an issue there, but no PR. |
Have the same issue. We need to have "Multiline" find option. |
👍 I Agree that this is something that is needed. |
Although this has been painful enough for long enough, I think we're nearly out of the woods. The proposal went to Stage 4 seven months ago, and the kangax tables list it as an ES2018 feature http://kangax.github.io/compat-table/es2016plus/. I don't know the guts of Atom to know even what JS engine it's running or what ES features are supported, but I suspect we're either at the point (or will be very soon) where we could just have a button added on the Atom find UI to include the |
Mmm.. yeah. We're all probably naively thinking "how hard could it be?", but the realities of performance and scaling when dealing with large files isn't trivial. I wonder if other editors' approaches could be looked at to see how they accomplish it. For now, remembering to use |
@jinglesthula This very issue has prompted me to start an ESDiscuss thread about what would be required to fix this. But most certainly, the more intuitively simple something is conceptually, the more complex it really becomes behind the scenes to do correctly, ironically enough. |
I know It has been a long time, but I've been trying a solution for this issue for a while. So, here are my 2¢:
Find: Result:
Screenshots Before "Replace": After "Replace": Atom: 1.35.1 x64, macOS Mojave 10.14.4Does it help? |
No. |
@g3ar Could you give more details, please? |
I'm not using atom right now. Your solution works for simple files. I have tried this for complicated sources and it fails. I think problem is in wrong parsing of |
@g3ar I understand. I've tested it in a file (html+javascript+json) with 14,448 lines and it worked fine. However, I'm using Atom. I believe that different regex flavors require different regex structures. I don't know if you already did it but, if not, you could try to identify which flavor/engine you're using and then try another solution. Here's a list of them: https://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines Good luck and thank you for the details. |
My two cents. It works for single files, but not for multifiles. I have plenty of files with this code (sidebar, HTML static):
I want to add a new class (let's call it newclass) to the <li> element, but only when the link links to employees.html, so my regexp: Works for single files (finds the expression), but fails to find a single match if I look for multi-files (Shift+Option+F). |
the "find all" works fine in a single file, but multi-file doesn't work. Is there a workaround available ? (other then opening 100's of files to run this manually) ? I want to remove double lines :
|
Originally reported by @cydrobolt over at atom/atom#3892
Both regex and normal find can't search across lines. E.g
For the second example, a regex of
<p>.*</p>
should have matched the text. However, it does not work, because it is spread across two lines.The text was updated successfully, but these errors were encountered: