qword 1.1.15 → 1.1.16

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 CHANGED
@@ -1,3 +1,8 @@
1
+ 2026.09.07, v1.1.16
2
+
3
+ fix:
4
+ - 89f550a double enter in vim mode
5
+
1
6
  2026.09.07, v1.1.15
2
7
 
3
8
  fix:
package/client/create.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  keymapExtension,
20
20
  themeExtension,
21
21
  languageExtension,
22
- } from './options.js';
22
+ } from './options/options.js';
23
23
  import {markField, lineField} from './decorations.js';
24
24
 
25
25
  export function createEditor(element, options = {}) {
@@ -3,7 +3,7 @@ import {
3
3
  type CreateEditorOptions,
4
4
  } from './create.js';
5
5
  import type {MarkHandle} from './decorations.js';
6
- import type {OptionKey, OptionValue} from './options.js';
6
+ import type {OptionKey, OptionValue} from './options/options.js';
7
7
  import type {
8
8
  SourceCode,
9
9
  SourcePosition,
package/client/editor.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  addLineClass,
13
13
  removeLineClass,
14
14
  } from './decorations.js';
15
- import {setOption} from './options.js';
15
+ import {setOption} from './options/options.js';
16
16
  import {clearHistory} from './history.js';
17
17
  import {observeResize} from './dom.js';
18
18
 
package/client/index.d.ts CHANGED
@@ -47,7 +47,7 @@ export {
47
47
  setOption,
48
48
  type OptionKey,
49
49
  type OptionValue,
50
- } from './options.js';
50
+ } from './options/options.js';
51
51
  export {clearHistory} from './history.js';
52
52
  export {highlightStyle} from './highlight.js';
53
53
  export type {
package/client/index.js CHANGED
@@ -33,6 +33,6 @@ export {
33
33
  languageExtension,
34
34
  indentKeymap,
35
35
  setOption,
36
- } from './options.js';
36
+ } from './options/options.js';
37
37
  export {clearHistory} from './history.js';
38
38
  export {highlightStyle} from './highlight.js';
@@ -1,10 +1,10 @@
1
1
  import {type Extension} from '@codemirror/state';
2
- import type {QwordEditorView} from './create.js';
2
+ import type {QwordEditorView} from '../create.js';
3
3
  import type {
4
4
  KeyMap,
5
5
  EditorMode,
6
6
  EditorTheme,
7
- } from './types.js';
7
+ } from '../types.js';
8
8
 
9
9
  export function keymapExtension(name: KeyMap): Extension;
10
10
 
@@ -12,6 +12,8 @@ import {
12
12
  insertNewlineAndIndent,
13
13
  } from '@codemirror/commands';
14
14
 
15
+ import {keepIndentAfterEnterVim} from './vim/keep-indent-after-enter-vim.js';
16
+
15
17
  const enterKeepIndent = {
16
18
  key: 'Enter',
17
19
  run: insertNewlineAndIndent,
@@ -19,7 +21,10 @@ const enterKeepIndent = {
19
21
 
20
22
  export function keymapExtension(name) {
21
23
  if (name === 'vim')
22
- return vim();
24
+ return keymap.of([
25
+ vim(),
26
+ keepIndentAfterEnterVim,
27
+ ]);
23
28
 
24
29
  if (name === 'emacs')
25
30
  return keymap.of([...emacsStyleKeymap, indentWithTab]);
@@ -0,0 +1,52 @@
1
+ import {EditorState, Prec} from '@codemirror/state';
2
+
3
+ export const keepIndentAfterEnterVim = EditorState.transactionFilter.of((tr) => {
4
+ if (!tr.docChanged)
5
+ return tr;
6
+
7
+ const selection = tr.newSelection.main;
8
+
9
+ if (!selection.empty)
10
+ return tr;
11
+
12
+ const pos = selection.head;
13
+ const line = tr.newDoc.lineAt(pos);
14
+
15
+ if (pos !== line.from)
16
+ return tr;
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
+ if (line.number === 1)
30
+ return tr;
31
+
32
+ const previousLine = tr.newDoc.line(line.number - 1);
33
+ const match = previousLine.text.match(/^\s*/);
34
+ const indent = match?.[0] || '';
35
+
36
+ if (!indent)
37
+ return tr;
38
+
39
+ return [
40
+ tr, {
41
+ changes: {
42
+ from: pos,
43
+ to: pos,
44
+ insert: indent,
45
+ },
46
+ selection: {
47
+ anchor: pos + indent.length,
48
+ },
49
+ },
50
+ ];
51
+ });
52
+