@codemirror/autocomplete 6.16.1 → 6.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 6.16.2 (2024-05-31)
2
+
3
+ ### Bug fixes
4
+
5
+ Allow backslash-escaped closing braces inside snippet field names/content.
6
+
1
7
  ## 6.16.1 (2024-05-29)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1401,8 +1401,9 @@ class Snippet {
1401
1401
  let fields = [];
1402
1402
  let lines = [], positions = [], m;
1403
1403
  for (let line of template.split(/\r\n?|\n/)) {
1404
- while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(line)) {
1405
- let seq = m[1] ? +m[1] : null, name = m[2] || m[3] || "", found = -1;
1404
+ while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(line)) {
1405
+ let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
1406
+ let name = rawName.replace(/\\[{}]/g, m => m[1]);
1406
1407
  for (let i = 0; i < fields.length; i++) {
1407
1408
  if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
1408
1409
  found = i;
@@ -1418,7 +1419,7 @@ class Snippet {
1418
1419
  pos.field++;
1419
1420
  }
1420
1421
  positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
1421
- line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
1422
+ line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length);
1422
1423
  }
1423
1424
  line = line.replace(/\\([{}])/g, (_, brace, index) => {
1424
1425
  for (let pos of positions)
package/dist/index.js CHANGED
@@ -1399,8 +1399,9 @@ class Snippet {
1399
1399
  let fields = [];
1400
1400
  let lines = [], positions = [], m;
1401
1401
  for (let line of template.split(/\r\n?|\n/)) {
1402
- while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(line)) {
1403
- let seq = m[1] ? +m[1] : null, name = m[2] || m[3] || "", found = -1;
1402
+ while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(line)) {
1403
+ let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
1404
+ let name = rawName.replace(/\\[{}]/g, m => m[1]);
1404
1405
  for (let i = 0; i < fields.length; i++) {
1405
1406
  if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
1406
1407
  found = i;
@@ -1416,7 +1417,7 @@ class Snippet {
1416
1417
  pos.field++;
1417
1418
  }
1418
1419
  positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
1419
- line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
1420
+ line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length);
1420
1421
  }
1421
1422
  line = line.replace(/\\([{}])/g, (_, brace, index) => {
1422
1423
  for (let pos of positions)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/autocomplete",
3
- "version": "6.16.1",
3
+ "version": "6.16.2",
4
4
  "description": "Autocompletion for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",