@codemirror/autocomplete 6.0.0 → 6.0.3
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/.github/workflows/dispatch.yml +1 -1
- package/CHANGELOG.md +18 -0
- package/README.md +5 -5
- package/dist/index.cjs +22 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -1
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 6.0.3 (2022-07-04)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix a bug that caused `closeBrackets` to not close quotes when at the end of a syntactic construct that starts with a similar quote.
|
|
6
|
+
|
|
7
|
+
## 6.0.2 (2022-06-15)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Declare package dependencies as peer dependencies as an attempt to avoid duplicated package issues.
|
|
12
|
+
|
|
13
|
+
## 6.0.1 (2022-06-09)
|
|
14
|
+
|
|
15
|
+
### Bug fixes
|
|
16
|
+
|
|
17
|
+
Support escaping `${` or `#{` in snippets.
|
|
18
|
+
|
|
1
19
|
## 6.0.0 (2022-06-08)
|
|
2
20
|
|
|
3
21
|
### Bug fixes
|
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# @codemirror/autocomplete [](https://www.npmjs.org/package/@codemirror/autocomplete)
|
|
2
2
|
|
|
3
|
-
[ [**WEBSITE**](https://codemirror.net/
|
|
3
|
+
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#autocomplete) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/autocomplete/blob/main/CHANGELOG.md) ]
|
|
4
4
|
|
|
5
5
|
This package implements autocompletion for the
|
|
6
|
-
[CodeMirror](https://codemirror.net/
|
|
6
|
+
[CodeMirror](https://codemirror.net/) code editor.
|
|
7
7
|
|
|
8
|
-
The [project page](https://codemirror.net/
|
|
9
|
-
number of [examples](https://codemirror.net/
|
|
10
|
-
[documentation](https://codemirror.net/
|
|
8
|
+
The [project page](https://codemirror.net/) has more information, a
|
|
9
|
+
number of [examples](https://codemirror.net/examples/) and the
|
|
10
|
+
[documentation](https://codemirror.net/docs/).
|
|
11
11
|
|
|
12
12
|
This code is released under an
|
|
13
13
|
[MIT license](https://github.com/codemirror/autocomplete/tree/main/LICENSE).
|
package/dist/index.cjs
CHANGED
|
@@ -1181,6 +1181,14 @@ class Snippet {
|
|
|
1181
1181
|
positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
|
|
1182
1182
|
line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
|
|
1183
1183
|
}
|
|
1184
|
+
for (let esc; esc = /([$#])\\{/.exec(line);) {
|
|
1185
|
+
line = line.slice(0, esc.index) + esc[1] + "{" + line.slice(esc.index + esc[0].length);
|
|
1186
|
+
for (let pos of positions)
|
|
1187
|
+
if (pos.line == lines.length && pos.from > esc.index) {
|
|
1188
|
+
pos.from--;
|
|
1189
|
+
pos.to--;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1184
1192
|
lines.push(line);
|
|
1185
1193
|
}
|
|
1186
1194
|
return new Snippet(lines, positions);
|
|
@@ -1264,6 +1272,11 @@ cursor out of the current field deactivates the fields.
|
|
|
1264
1272
|
The order of fields defaults to textual order, but you can add
|
|
1265
1273
|
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
|
|
1266
1274
|
a custom order.
|
|
1275
|
+
|
|
1276
|
+
To include a literal `${` or `#{` in your template, put a
|
|
1277
|
+
backslash after the dollar or hash and before the brace (`$\\{`).
|
|
1278
|
+
This will be removed and the sequence will not be interpreted as a
|
|
1279
|
+
placeholder.
|
|
1267
1280
|
*/
|
|
1268
1281
|
function snippet(template) {
|
|
1269
1282
|
let snippet = Snippet.parse(template);
|
|
@@ -1649,10 +1662,18 @@ function nodeStart(state, pos) {
|
|
|
1649
1662
|
return tree.parent && tree.from == pos;
|
|
1650
1663
|
}
|
|
1651
1664
|
function probablyInString(state, pos, quoteToken) {
|
|
1665
|
+
console.log('check pos', pos);
|
|
1652
1666
|
let node = language.syntaxTree(state).resolveInner(pos, -1);
|
|
1653
1667
|
for (let i = 0; i < 5; i++) {
|
|
1654
|
-
if (state.sliceDoc(node.from, node.from + quoteToken.length) == quoteToken)
|
|
1668
|
+
if (state.sliceDoc(node.from, node.from + quoteToken.length) == quoteToken) {
|
|
1669
|
+
let first = node.firstChild;
|
|
1670
|
+
while (first && first.from == node.from && first.to - first.from > quoteToken.length) {
|
|
1671
|
+
if (state.sliceDoc(first.to - quoteToken.length, first.to) == quoteToken)
|
|
1672
|
+
return false;
|
|
1673
|
+
first = first.firstChild;
|
|
1674
|
+
}
|
|
1655
1675
|
return true;
|
|
1676
|
+
}
|
|
1656
1677
|
let parent = node.to == pos && node.parent;
|
|
1657
1678
|
if (!parent)
|
|
1658
1679
|
break;
|
package/dist/index.d.ts
CHANGED
|
@@ -302,6 +302,11 @@ cursor out of the current field deactivates the fields.
|
|
|
302
302
|
The order of fields defaults to textual order, but you can add
|
|
303
303
|
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
|
|
304
304
|
a custom order.
|
|
305
|
+
|
|
306
|
+
To include a literal `${` or `#{` in your template, put a
|
|
307
|
+
backslash after the dollar or hash and before the brace (`$\\{`).
|
|
308
|
+
This will be removed and the sequence will not be interpreted as a
|
|
309
|
+
placeholder.
|
|
305
310
|
*/
|
|
306
311
|
declare function snippet(template: string): (editor: {
|
|
307
312
|
state: EditorState;
|
package/dist/index.js
CHANGED
|
@@ -1177,6 +1177,14 @@ class Snippet {
|
|
|
1177
1177
|
positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
|
|
1178
1178
|
line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
|
|
1179
1179
|
}
|
|
1180
|
+
for (let esc; esc = /([$#])\\{/.exec(line);) {
|
|
1181
|
+
line = line.slice(0, esc.index) + esc[1] + "{" + line.slice(esc.index + esc[0].length);
|
|
1182
|
+
for (let pos of positions)
|
|
1183
|
+
if (pos.line == lines.length && pos.from > esc.index) {
|
|
1184
|
+
pos.from--;
|
|
1185
|
+
pos.to--;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1180
1188
|
lines.push(line);
|
|
1181
1189
|
}
|
|
1182
1190
|
return new Snippet(lines, positions);
|
|
@@ -1260,6 +1268,11 @@ cursor out of the current field deactivates the fields.
|
|
|
1260
1268
|
The order of fields defaults to textual order, but you can add
|
|
1261
1269
|
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
|
|
1262
1270
|
a custom order.
|
|
1271
|
+
|
|
1272
|
+
To include a literal `${` or `#{` in your template, put a
|
|
1273
|
+
backslash after the dollar or hash and before the brace (`$\\{`).
|
|
1274
|
+
This will be removed and the sequence will not be interpreted as a
|
|
1275
|
+
placeholder.
|
|
1263
1276
|
*/
|
|
1264
1277
|
function snippet(template) {
|
|
1265
1278
|
let snippet = Snippet.parse(template);
|
|
@@ -1645,10 +1658,18 @@ function nodeStart(state, pos) {
|
|
|
1645
1658
|
return tree.parent && tree.from == pos;
|
|
1646
1659
|
}
|
|
1647
1660
|
function probablyInString(state, pos, quoteToken) {
|
|
1661
|
+
console.log('check pos', pos);
|
|
1648
1662
|
let node = syntaxTree(state).resolveInner(pos, -1);
|
|
1649
1663
|
for (let i = 0; i < 5; i++) {
|
|
1650
|
-
if (state.sliceDoc(node.from, node.from + quoteToken.length) == quoteToken)
|
|
1664
|
+
if (state.sliceDoc(node.from, node.from + quoteToken.length) == quoteToken) {
|
|
1665
|
+
let first = node.firstChild;
|
|
1666
|
+
while (first && first.from == node.from && first.to - first.from > quoteToken.length) {
|
|
1667
|
+
if (state.sliceDoc(first.to - quoteToken.length, first.to) == quoteToken)
|
|
1668
|
+
return false;
|
|
1669
|
+
first = first.firstChild;
|
|
1670
|
+
}
|
|
1651
1671
|
return true;
|
|
1672
|
+
}
|
|
1652
1673
|
let parent = node.to == pos && node.parent;
|
|
1653
1674
|
if (!parent)
|
|
1654
1675
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/autocomplete",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.3",
|
|
4
4
|
"description": "Autocompletion for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "cm-runtests",
|
|
@@ -31,6 +31,12 @@
|
|
|
31
31
|
"@codemirror/view": "^6.0.0",
|
|
32
32
|
"@lezer/common": "^1.0.0"
|
|
33
33
|
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@codemirror/language": "^6.0.0",
|
|
36
|
+
"@codemirror/state": "^6.0.0",
|
|
37
|
+
"@codemirror/view": "^6.0.0",
|
|
38
|
+
"@lezer/common": "^1.0.0"
|
|
39
|
+
},
|
|
34
40
|
"devDependencies": {
|
|
35
41
|
"@codemirror/buildhelper": "^0.1.5"
|
|
36
42
|
},
|