qword 1.1.16 → 1.1.17
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 +6 -0
- package/client/options/options.js +1 -4
- package/client/options/vim/keep-indent-after-enter-vim.js +19 -16
- package/dist/qword.js +2 -1
- package/dist/qword.js.map +1 -1
- package/dist-dev/qword.js +37 -37
- package/package.json +1 -1
- package/dist/2b22a33a0a80bb926bbc.png +0 -1
- package/dist/8e9019bd86255ac9a618.png +0 -1
- package/dist/codemirror.js +0 -2
- package/dist/codemirror.js.map +0 -1
- package/dist/dword.js +0 -2
- package/dist/dword.js.map +0 -1
- package/dist-dev/2b22a33a0a80bb926bbc.png +0 -1
- package/dist-dev/8e9019bd86255ac9a618.png +0 -1
- package/dist-dev/codemirror.js +0 -104
- package/dist-dev/dword.js +0 -960
package/ChangeLog
CHANGED
|
@@ -21,10 +21,7 @@ const enterKeepIndent = {
|
|
|
21
21
|
|
|
22
22
|
export function keymapExtension(name) {
|
|
23
23
|
if (name === 'vim')
|
|
24
|
-
return
|
|
25
|
-
vim(),
|
|
26
|
-
keepIndentAfterEnterVim,
|
|
27
|
-
]);
|
|
24
|
+
return [vim(), keepIndentAfterEnterVim];
|
|
28
25
|
|
|
29
26
|
if (name === 'emacs')
|
|
30
27
|
return keymap.of([...emacsStyleKeymap, indentWithTab]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {EditorState
|
|
1
|
+
import {EditorState} from '@codemirror/state';
|
|
2
2
|
|
|
3
3
|
export const keepIndentAfterEnterVim = EditorState.transactionFilter.of((tr) => {
|
|
4
4
|
if (!tr.docChanged)
|
|
@@ -15,38 +15,41 @@ export const keepIndentAfterEnterVim = EditorState.transactionFilter.of((tr) =>
|
|
|
15
15
|
if (pos !== line.from)
|
|
16
16
|
return tr;
|
|
17
17
|
|
|
18
|
-
let insertedNewline = false;
|
|
19
|
-
|
|
20
|
-
tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => {
|
|
21
|
-
if (inserted.toString().includes('\n'))
|
|
22
|
-
insertedNewline = true;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (!insertedNewline)
|
|
26
|
-
return tr;
|
|
27
|
-
|
|
28
|
-
// Берём indentation предыдущей строки.
|
|
29
18
|
if (line.number === 1)
|
|
30
19
|
return tr;
|
|
31
20
|
|
|
32
21
|
const previousLine = tr.newDoc.line(line.number - 1);
|
|
33
|
-
const
|
|
34
|
-
const indent = match?.[0] || '';
|
|
22
|
+
const indent = previousLine.text.match(/^\s*/)?.[0] || '';
|
|
35
23
|
|
|
36
24
|
if (!indent)
|
|
37
25
|
return tr;
|
|
38
26
|
|
|
27
|
+
let insertedNewline = false;
|
|
28
|
+
let alreadyIndented = false;
|
|
29
|
+
|
|
30
|
+
tr.changes.iterChanges((_fromA, _toA, _fromB, _toB, inserted) => {
|
|
31
|
+
const text = inserted.toString();
|
|
32
|
+
|
|
33
|
+
if (text.includes('\n'))
|
|
34
|
+
insertedNewline = true;
|
|
35
|
+
|
|
36
|
+
if (text.endsWith(`\n${indent}`))
|
|
37
|
+
alreadyIndented = true;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (!insertedNewline || alreadyIndented)
|
|
41
|
+
return tr;
|
|
42
|
+
|
|
39
43
|
return [
|
|
40
44
|
tr, {
|
|
41
45
|
changes: {
|
|
42
46
|
from: pos,
|
|
43
|
-
to: pos,
|
|
44
47
|
insert: indent,
|
|
45
48
|
},
|
|
46
49
|
selection: {
|
|
47
50
|
anchor: pos + indent.length,
|
|
48
51
|
},
|
|
52
|
+
sequential: true,
|
|
49
53
|
},
|
|
50
54
|
];
|
|
51
55
|
});
|
|
52
|
-
|