@codemirror/search
Advanced tools
Comparing version 6.2.1 to 6.2.2
@@ -0,1 +1,11 @@ | ||
## 6.2.2 (2022-10-18) | ||
### Bug fixes | ||
When `literal` is off, \n, \r, and \t escapes are now also supported in replacement text. | ||
Make sure search dialog inputs don't get treated as form fields when the editor is created inside a form. | ||
Fix a bug in `RegExpCursor` that would cause it to stop matching in the middle of a line when its current match position was equal to the length of the line. | ||
## 6.2.1 (2022-09-26) | ||
@@ -2,0 +12,0 @@ |
@@ -195,3 +195,3 @@ import { showPanel, EditorView, getPanel, Decoration, ViewPlugin, runScopeHandlers } from '@codemirror/view'; | ||
this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0)); | ||
if (from == this.curLine.length) | ||
if (from == this.curLineStart + this.curLine.length) | ||
this.nextLine(); | ||
@@ -590,6 +590,13 @@ if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) { | ||
this.valid = !!this.search && (!this.regexp || validRegExp(this.search)); | ||
this.unquoted = this.literal ? this.search : this.search.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\"); | ||
this.unquoted = this.unquote(this.search); | ||
this.wholeWord = !!config.wholeWord; | ||
} | ||
/** | ||
@internal | ||
*/ | ||
unquote(text) { | ||
return this.literal ? text : | ||
text.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\"); | ||
} | ||
/** | ||
Compare this query to another query. | ||
@@ -668,3 +675,3 @@ */ | ||
} | ||
getReplacement(_result) { return this.spec.replace; } | ||
getReplacement(_result) { return this.spec.unquote(this.spec.replace); } | ||
matchAll(state, limit) { | ||
@@ -728,6 +735,6 @@ let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = []; | ||
getReplacement(result) { | ||
return this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$" | ||
return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$" | ||
: i == "&" ? result.match[0] | ||
: i != "0" && +i < result.match.length ? result.match[i] | ||
: m); | ||
: m)); | ||
} | ||
@@ -1038,2 +1045,3 @@ matchAll(state, limit) { | ||
name: "search", | ||
form: "", | ||
"main-field": "true", | ||
@@ -1049,2 +1057,3 @@ onchange: this.commit, | ||
name: "replace", | ||
form: "", | ||
onchange: this.commit, | ||
@@ -1056,2 +1065,3 @@ onkeyup: this.commit | ||
name: "case", | ||
form: "", | ||
checked: query.caseSensitive, | ||
@@ -1063,2 +1073,3 @@ onchange: this.commit | ||
name: "re", | ||
form: "", | ||
checked: query.regexp, | ||
@@ -1070,2 +1081,3 @@ onchange: this.commit | ||
name: "word", | ||
form: "", | ||
checked: query.wholeWord, | ||
@@ -1072,0 +1084,0 @@ onchange: this.commit |
{ | ||
"name": "@codemirror/search", | ||
"version": "6.2.1", | ||
"version": "6.2.2", | ||
"description": "Search functionality for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116612
2770