-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Multiline Search Support: line breaks \n
#5675
base: master
Are you sure you want to change the base?
Conversation
* highlight line break * search line break * replace line break
Replace `.ace_search_form input` value with `\n` and `\t` using regex.
Does this also resolve #5674? |
ㅤ |
- Auto updates "updateCounter" and "ace_nomatch" in the search box when "onDocumentChange" - If regex mode is enabled, fill the "searchInput" field with "escapeRegExp"
src/search.js
Outdated
for (var matches, i = 0; i < lines.length; i++) { | ||
if (this.$isMultilineSearch(options)) { | ||
matches = this.$multiLineForward(session, re, i, lines.length); | ||
ranges.push(new Range(matches.startRow, matches.startCol, matches.endRow, matches.endCol)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 as the previous case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK.
src/search.js
Outdated
@@ -166,11 +240,15 @@ class Search { | |||
if (!re) | |||
return; | |||
|
|||
if (this.$isMultilineSearch(options)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are used at 2 places should we create another method as this looks like the reusable code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK.
src/search.js
Outdated
var column = matches[i - 1]; | ||
var length = matches[i]; | ||
if (callback(row, column, row, column + length)) | ||
if (multiline) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we reset regex lastIndex above this line just to reset it?
re.lastIndex = 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see: https://stackoverflow.com/a/4724920
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I wasn’t focused earlier.
No need, because it’s already set in multiLineBackwardMatch
.
Hey @sekedus |
Done. https://sekedus.github.io/ace/src/test/tests.html?ace/search_test |
3a15da5
to
cfb17ca
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5675 +/- ##
==========================================
- Coverage 87.01% 86.95% -0.07%
==========================================
Files 598 598
Lines 43680 43801 +121
Branches 7204 7208 +4
==========================================
+ Hits 38009 38085 +76
- Misses 5671 5716 +45
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@sekedus some test case requirement is failing will you be able to resolve this? |
Sorry, I don't know where the error is and how to resolve it. Any suggestions? |
src/editor.js
Outdated
|
||
// Updates "updateCounter" and "ace_nomatch" in the search box | ||
if (this.searchBox && this.searchBox.active === true) | ||
this.searchBox.find(false, false, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move this to an input event handler in searchbox, something like editor.on('input', this.$onEditorInput)
and remove the listener when deactivating. onDocumentChange
can be called multiple times during one edit, and input event debounces that with a timeout.
Also in one of tests add a scenario of changing editor value, e.g.
editor.insert("searchedText")
setTimeout(function() {
// verify that search counter have been updated
}, 50)
to prevent coverlay complaining about untested lines
@sekedus The failure of checks is due to some lines of code not having test cases. |
56f0455
to
23b06f9
Compare
\n
\n
Issue #2869
Description of changes:
\n
\n
\n
\n
or\t
ㅤ
Benefit
Users can now perform search/replace line breaks (
\n
) with regex.ㅤ
Test
Document: JavaScript
Open search box
\n
or\n+
or\n\s+
or\)\s\{\n\s+
Example:
\n{2}
with\n
\n+
with\n
\n
with{empty}
{any_string}
with\n
or\t
ㅤ
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Pull Request Checklist:
ace.d.ts
) and its references: