@codemirror/search
Advanced tools
Comparing version 6.5.8 to 6.5.9
@@ -0,1 +1,7 @@ | ||
## 6.5.9 (2025-02-12) | ||
### Bug fixes | ||
When replacing a regexp match, don't expand multi-digit replacement markers to numbers beyond the captured group count in the query. | ||
## 6.5.8 (2024-11-22) | ||
@@ -2,0 +8,0 @@ |
@@ -738,6 +738,14 @@ import { showPanel, EditorView, getPanel, Decoration, ViewPlugin, runScopeHandlers } from '@codemirror/view'; | ||
getReplacement(result) { | ||
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); | ||
return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g, (m, i) => { | ||
if (i == "&") | ||
return result.match[0]; | ||
if (i == "$") | ||
return "$"; | ||
for (let l = i.length; l > 0; l--) { | ||
let n = +i.slice(0, l); | ||
if (n > 0 && n < result.match.length) | ||
return result.match[n] + i.slice(l); | ||
} | ||
return m; | ||
}); | ||
} | ||
@@ -744,0 +752,0 @@ matchAll(state, limit) { |
{ | ||
"name": "@codemirror/search", | ||
"version": "6.5.8", | ||
"version": "6.5.9", | ||
"description": "Search functionality for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
134297
2830