You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiline find in file (Ctrl+F) does not work for \s or [^] regular expressions #9051
anseki We use JavaScript's regular expression engine behind the scene, so the supported syntax should be that of JavaScript regex. We do not have plans to switch to a different regular expression engine.
At least, V8 in Electron seems to interpret regular expressions correctly.
For example:
VS Code menu "Help" -> "Toggle Developer Tools" -> "Console"
'<A\nB\nC>'.replace(/<[ABC\s]*>/,'OK')
'<A\nB\nC>'.replace(/<[^]*>/,'OK')
Two strings that include line breaks were replaced correctly, and OK was shown.
I think, if regular expression of VS Code differs from JavaScript, the information should be documented. Because the pattern matches a string which doesn't include line break, we might overlook something important.
anseki Sorry about that! Now I understand what's going on.
To optimize on memory usage we do the following:
here we preparse the search string and look for \n or \r. If we find \n or \r in the search string we assume this was a multiline search
then, to optimize memory usage (not concatenate the entire buffer into a string) we have two search strategies, either we search line by line (if the search string indicates this is not a multiline search) or we search in the concatenated string.
Looks like the heuristic is wrong, as \s and [^] should also use the multiline version of the find matches.
I read that code and I thought that this issue is difficult, because it can't decide whether the pattern get multiline or not by only keyword or characters.
For example, [^x], \x0a, [\x09-\x0b] and other patterns also match line break.
I think, only some patterns that are commonly used such as \s and [^] should be supported. And the information should be documented.
[\s\S] and [^] are used to make it match any character.
For example, HTML comment: <!--[^]*?-->
roblourens what does "global search" mean in #13155? I thought it was about searching in multiple files, which this issue is not, but please correct me if I'm wrong.
changed the title [-]Multiline Find seems not work completely[/-][+]Multiline find in file (Ctrl+F) does not work for \s or [^] regular expressions[/+]on Nov 24, 2017
Activity
alexdima commentedon Jul 11, 2016
anseki We use JavaScript's regular expression engine behind the scene, so the supported syntax should be that of JavaScript regex. We do not have plans to switch to a different regular expression engine.
anseki commentedon Jul 11, 2016
At least, V8 in Electron seems to interpret regular expressions correctly.
For example:
VS Code menu "Help" -> "Toggle Developer Tools" -> "Console"
Two strings that include line breaks were replaced correctly, and
OKwas shown.I think, if regular expression of VS Code differs from JavaScript, the information should be documented. Because the pattern matches a string which doesn't include line break, we might overlook something important.
alexdima commentedon Jul 11, 2016
anseki Sorry about that! Now I understand what's going on.
To optimize on memory usage we do the following:
\nor\r. If we find\nor\rin the search string we assume this was a multiline searchLooks like the heuristic is wrong, as
\sand[^]should also use the multiline version of the find matches.anseki commentedon Jul 11, 2016
Sorry, my wrong English...
I read that code and I thought that this issue is difficult, because it can't decide whether the pattern get multiline or not by only keyword or characters.
For example,
[^x],\x0a,[\x09-\x0b]and other patterns also match line break.I think, only some patterns that are commonly used such as
\sand[^]should be supported. And the information should be documented.[\s\S]and[^]are used to make it match any character.For example, HTML comment:
<!--[^]*?-->8 remaining items
roblourens commentedon Oct 28, 2017
#13155
waldyrious commentedon Oct 28, 2017
roblourens what does "global search" mean in #13155? I thought it was about searching in multiple files, which this issue is not, but please correct me if I'm wrong.
[-]Multiline Find seems not work completely[/-][+]Multiline find in file (Ctrl+F) does not work for \s or [^] regular expressions[/+]alexdima commentedon Apr 20, 2018
Peng Lyu (@rebornix) This might be a non-issue with our new textbuffer / search implementation?
i.e. there is no longer a need to optimize searching line-by-line
rebornix commentedon Sep 21, 2018
No longer see above issues as our new text buffer doesn't try to do line by line optimization anymore.