@bhsd/codemirror-mediawiki 3.10.0 → 3.10.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/README.md +78 -78
- package/dist/bidi.d.ts +5 -0
- package/dist/bidi.js +5 -0
- package/dist/codemirror.d.ts +7 -0
- package/dist/codemirror.js +10 -3
- package/dist/color.d.ts +7 -4
- package/dist/color.js +4 -0
- package/dist/css.d.ts +5 -0
- package/dist/css.js +5 -0
- package/dist/escape.d.ts +21 -1
- package/dist/escape.js +42 -24
- package/dist/fold.d.ts +55 -3
- package/dist/fold.js +54 -30
- package/dist/hover.d.ts +14 -1
- package/dist/hover.js +49 -31
- package/dist/html.js +17 -12
- package/dist/indent.d.ts +7 -0
- package/dist/indent.js +7 -1
- package/dist/inlay.js +1 -1
- package/dist/javascript.d.ts +10 -1
- package/dist/javascript.js +6 -1
- package/dist/keybindings.d.ts +1 -0
- package/dist/keybindings.js +1 -0
- package/dist/keymap.d.ts +11 -0
- package/dist/keymap.js +3 -4
- package/dist/linter.d.ts +16 -0
- package/dist/linter.js +8 -1
- package/dist/lintsource.d.ts +36 -4
- package/dist/lintsource.js +37 -4
- package/dist/lua.js +31 -20
- package/dist/main.min.js +29 -29
- package/dist/matchBrackets.d.ts +16 -0
- package/dist/matchBrackets.js +16 -0
- package/dist/matchTag.d.ts +5 -2
- package/dist/matchTag.js +7 -4
- package/dist/mediawiki.d.ts +11 -0
- package/dist/mediawiki.js +8 -4
- package/dist/mw.min.js +31 -31
- package/dist/mwConfig.js +1 -1
- package/dist/openLinks.d.ts +8 -0
- package/dist/openLinks.js +8 -0
- package/dist/ref.d.ts +15 -1
- package/dist/ref.js +81 -65
- package/dist/signature.d.ts +6 -0
- package/dist/signature.js +22 -19
- package/dist/static.d.ts +4 -0
- package/dist/static.js +4 -0
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +3 -1
- package/dist/token.d.ts +9 -1
- package/dist/token.js +12 -6
- package/dist/util.d.ts +8 -0
- package/dist/util.js +8 -0
- package/dist/wiki.min.js +30 -30
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +22 -22
package/dist/keymap.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type { KeyBinding } from '@codemirror/view';
|
|
2
|
+
import type { KeymapConfig } from './keybindings';
|
|
3
|
+
/**
|
|
4
|
+
* 生成keymap
|
|
5
|
+
* @param opt 快捷键设置
|
|
6
|
+
* @param opt.key 键名
|
|
7
|
+
* @param opt.pre 前缀
|
|
8
|
+
* @param opt.post 后缀
|
|
9
|
+
* @param opt.splitlines 是否分行
|
|
10
|
+
* @test
|
|
11
|
+
*/
|
|
12
|
+
export declare const getKeymap: ({ key, pre, post, splitlines }: KeymapConfig) => KeyBinding;
|
|
2
13
|
declare const _default: KeyBinding[];
|
|
3
14
|
export default _default;
|
package/dist/keymap.js
CHANGED
|
@@ -7,8 +7,9 @@ import { keybindings, encapsulateLines } from './keybindings.js';
|
|
|
7
7
|
* @param opt.pre 前缀
|
|
8
8
|
* @param opt.post 后缀
|
|
9
9
|
* @param opt.splitlines 是否分行
|
|
10
|
+
* @test
|
|
10
11
|
*/
|
|
11
|
-
const getKeymap = ({ key, pre = '', post = '', splitlines }) => ({
|
|
12
|
+
export const getKeymap = ({ key, pre = '', post = '', splitlines }) => ({
|
|
12
13
|
key,
|
|
13
14
|
run(view) {
|
|
14
15
|
const { state } = view;
|
|
@@ -22,9 +23,7 @@ const getKeymap = ({ key, pre = '', post = '', splitlines }) => ({
|
|
|
22
23
|
}
|
|
23
24
|
const insert = pre + state.sliceDoc(from, to) + post, head = from + insert.length;
|
|
24
25
|
return {
|
|
25
|
-
range: from === to
|
|
26
|
-
? EditorSelection.range(from + pre.length, head - post.length)
|
|
27
|
-
: EditorSelection.range(head, head),
|
|
26
|
+
range: EditorSelection.cursor(from === to ? from + pre.length : head),
|
|
28
27
|
changes: { from, to, insert },
|
|
29
28
|
};
|
|
30
29
|
}));
|
package/dist/linter.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Diagnostic as DiagnosticBase, Range, Position } from 'vscode-langu
|
|
|
2
2
|
import type { Linter } from 'eslint';
|
|
3
3
|
import type { Warning } from 'stylelint/types/stylelint';
|
|
4
4
|
import type { Diagnostic } from 'luacheck-browserify';
|
|
5
|
+
import type { AST } from 'wikiparser-node';
|
|
5
6
|
export type Option = Record<string, unknown> | null | undefined;
|
|
6
7
|
export type LiveOption = (runtime?: boolean) => Option | Promise<Option>;
|
|
7
8
|
declare type asyncLinter<T, S = Record<string, unknown>> = ((text: string, config?: Option) => T) & {
|
|
@@ -25,12 +26,23 @@ export declare const eslintRepo = "npm/@bhsd/eslint-browserify", luacheckRepo =
|
|
|
25
26
|
* @param range 范围
|
|
26
27
|
* @param lineOrOffset 行号或相对位置
|
|
27
28
|
* @param column 列号
|
|
29
|
+
* @test
|
|
28
30
|
*/
|
|
29
31
|
export declare const offsetAt: (range: [number, number], lineOrOffset: number, column?: number) => number;
|
|
32
|
+
/**
|
|
33
|
+
* 获取伪CSS代码块的前缀
|
|
34
|
+
* @param token AST 节点
|
|
35
|
+
* @param token.type 节点类型
|
|
36
|
+
* @param token.tag 节点标签
|
|
37
|
+
* @param i 节点序号
|
|
38
|
+
* @test
|
|
39
|
+
*/
|
|
40
|
+
export declare const getPrefix: ({ type, tag }: AST, i: number) => string;
|
|
30
41
|
/**
|
|
31
42
|
* 将偏移量转换为位置
|
|
32
43
|
* @param code 代码字符串
|
|
33
44
|
* @param index 偏移量
|
|
45
|
+
* @test
|
|
34
46
|
*/
|
|
35
47
|
export declare const indexToPos: (code: string, index: number) => Position;
|
|
36
48
|
/**
|
|
@@ -38,22 +50,26 @@ export declare const indexToPos: (code: string, index: number) => Position;
|
|
|
38
50
|
* @param opt 选项
|
|
39
51
|
* @param opt.cdn jsDelivr CDN,不含库名
|
|
40
52
|
* @param obj 对象
|
|
53
|
+
* @test
|
|
41
54
|
*/
|
|
42
55
|
export declare const getWikiLinter: getAsyncLinter<Promise<MixedDiagnostic[]>, Option, object>;
|
|
43
56
|
export declare const jsConfig: Option;
|
|
44
57
|
/**
|
|
45
58
|
* 获取 ESLint
|
|
46
59
|
* @param cdn CDN 地址
|
|
60
|
+
* @test
|
|
47
61
|
*/
|
|
48
62
|
export declare const getJsLinter: getAsyncLinter<Linter.LintMessage[], string>;
|
|
49
63
|
/**
|
|
50
64
|
* 获取 Stylelint
|
|
51
65
|
* @param cdn CDN 地址
|
|
66
|
+
* @test
|
|
52
67
|
*/
|
|
53
68
|
export declare const getCssLinter: getAsyncLinter<Promise<Warning[]>, string>;
|
|
54
69
|
/**
|
|
55
70
|
* 获取 Luacheck
|
|
56
71
|
* @param cdn CDN 地址
|
|
72
|
+
* @test
|
|
57
73
|
*/
|
|
58
74
|
export declare const getLuaLinter: getAsyncLinter<Promise<Diagnostic[]>, string>;
|
|
59
75
|
export {};
|
package/dist/linter.js
CHANGED
|
@@ -8,6 +8,7 @@ export const eslintRepo = 'npm/@bhsd/eslint-browserify', luacheckRepo = 'npm/lua
|
|
|
8
8
|
* @param range 范围
|
|
9
9
|
* @param lineOrOffset 行号或相对位置
|
|
10
10
|
* @param column 列号
|
|
11
|
+
* @test
|
|
11
12
|
*/
|
|
12
13
|
export const offsetAt = (range, lineOrOffset, column) => {
|
|
13
14
|
if (column === undefined) {
|
|
@@ -24,12 +25,14 @@ export const offsetAt = (range, lineOrOffset, column) => {
|
|
|
24
25
|
* @param token.type 节点类型
|
|
25
26
|
* @param token.tag 节点标签
|
|
26
27
|
* @param i 节点序号
|
|
28
|
+
* @test
|
|
27
29
|
*/
|
|
28
|
-
const getPrefix = ({ type, tag }, i) => `${type === 'ext-attr' ? 'div' : tag}#${i}{\n`;
|
|
30
|
+
export const getPrefix = ({ type, tag }, i) => `${type === 'ext-attr' ? 'div' : tag}#${i}{\n`;
|
|
29
31
|
/**
|
|
30
32
|
* 将偏移量转换为位置
|
|
31
33
|
* @param code 代码字符串
|
|
32
34
|
* @param index 偏移量
|
|
35
|
+
* @test
|
|
33
36
|
*/
|
|
34
37
|
export const indexToPos = (code, index) => {
|
|
35
38
|
const lines = code.slice(0, index).split('\n');
|
|
@@ -45,6 +48,7 @@ const isStylelintConfig = (config) => Boolean(config && ('extends' in config ||
|
|
|
45
48
|
* @param opt 选项
|
|
46
49
|
* @param opt.cdn jsDelivr CDN,不含库名
|
|
47
50
|
* @param obj 对象
|
|
51
|
+
* @test
|
|
48
52
|
*/
|
|
49
53
|
export const getWikiLinter = async (opt, obj) => {
|
|
50
54
|
const cdn = opt?.['cdn'];
|
|
@@ -120,6 +124,7 @@ export const jsConfig = /* #__PURE__ */ (() => ({
|
|
|
120
124
|
/**
|
|
121
125
|
* 获取 ESLint
|
|
122
126
|
* @param cdn CDN 地址
|
|
127
|
+
* @test
|
|
123
128
|
*/
|
|
124
129
|
export const getJsLinter = async (cdn = eslintRepo) => {
|
|
125
130
|
await loadScript(cdn, 'eslint');
|
|
@@ -151,6 +156,7 @@ export const getJsLinter = async (cdn = eslintRepo) => {
|
|
|
151
156
|
/**
|
|
152
157
|
* 获取 Stylelint
|
|
153
158
|
* @param cdn CDN 地址
|
|
159
|
+
* @test
|
|
154
160
|
*/
|
|
155
161
|
export const getCssLinter = async (cdn = stylelintRepo) => {
|
|
156
162
|
await loadScript(cdn, 'stylelint');
|
|
@@ -170,6 +176,7 @@ export const getCssLinter = async (cdn = stylelintRepo) => {
|
|
|
170
176
|
/**
|
|
171
177
|
* 获取 Luacheck
|
|
172
178
|
* @param cdn CDN 地址
|
|
179
|
+
* @test
|
|
173
180
|
*/
|
|
174
181
|
export const getLuaLinter = async (cdn = luacheckRepo) => {
|
|
175
182
|
await loadScript(cdn, 'luacheck');
|
package/dist/lintsource.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Text, EditorState } from '@codemirror/state';
|
|
|
3
3
|
import type { Language } from '@codemirror/language';
|
|
4
4
|
import type { Diagnostic, Action } from '@codemirror/lint';
|
|
5
5
|
import type { Option, LiveOption } from './linter';
|
|
6
|
+
import type { DocRange } from './fold';
|
|
6
7
|
export type LintSource = ((state: EditorState) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>) & {
|
|
7
8
|
fixer?: (doc: Text, rule?: string) => string | Promise<string>;
|
|
8
9
|
};
|
|
@@ -23,16 +24,47 @@ export declare const getOpt: (opt: Option | LiveOption, runtime?: boolean) => Op
|
|
|
23
24
|
* @param line 行号
|
|
24
25
|
* @param column 列号
|
|
25
26
|
* @param from 子语言起始位置
|
|
27
|
+
* @test
|
|
26
28
|
*/
|
|
27
29
|
export declare const pos: (doc: Text, line: number, column: number, from?: number) => number;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* 将行列范围转换为位置范围
|
|
32
|
+
* @ignore
|
|
33
|
+
* @test
|
|
34
|
+
*/
|
|
35
|
+
export declare const getRange: (doc: Text, line: number, column: number, endLine?: number, endColumn?: number, f?: number, t?: number) => DocRange;
|
|
36
|
+
/**
|
|
37
|
+
* @implements
|
|
38
|
+
* @test
|
|
39
|
+
*/
|
|
32
40
|
export declare const getWikiLintSource: (articlePath?: string) => LintSourceGetter;
|
|
41
|
+
/**
|
|
42
|
+
* @implements
|
|
43
|
+
* @test
|
|
44
|
+
*/
|
|
33
45
|
export declare const getJsLintSource: LintSourceGetter;
|
|
46
|
+
/**
|
|
47
|
+
* @implements
|
|
48
|
+
* @test
|
|
49
|
+
*/
|
|
34
50
|
export declare const getCssLintSource: LintSourceGetter;
|
|
51
|
+
/**
|
|
52
|
+
* @implements
|
|
53
|
+
* @test
|
|
54
|
+
*/
|
|
35
55
|
export declare const getVueLintSource: LintSourceGetter;
|
|
56
|
+
/**
|
|
57
|
+
* @implements
|
|
58
|
+
* @test
|
|
59
|
+
*/
|
|
36
60
|
export declare const getHTMLLintSource: LintSourceGetter;
|
|
61
|
+
/**
|
|
62
|
+
* @implements
|
|
63
|
+
* @test
|
|
64
|
+
*/
|
|
37
65
|
export declare const getJsonLintSource: LintSourceGetter;
|
|
66
|
+
/**
|
|
67
|
+
* @implements
|
|
68
|
+
* @test
|
|
69
|
+
*/
|
|
38
70
|
export declare const getLuaLintSource: LintSourceGetter;
|
package/dist/lintsource.js
CHANGED
|
@@ -17,6 +17,7 @@ export const getOpt = (opt, runtime) => typeof opt === 'function' ? opt(runtime)
|
|
|
17
17
|
* @param line 行号
|
|
18
18
|
* @param column 列号
|
|
19
19
|
* @param from 子语言起始位置
|
|
20
|
+
* @test
|
|
20
21
|
*/
|
|
21
22
|
export const pos = (doc, line, column, from = 0) => {
|
|
22
23
|
if (from === 0) {
|
|
@@ -28,6 +29,11 @@ export const pos = (doc, line, column, from = 0) => {
|
|
|
28
29
|
character: (line === 1 ? from - lineDesc.from : 0) + column - 1,
|
|
29
30
|
});
|
|
30
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* 将行列范围转换为位置范围
|
|
34
|
+
* @ignore
|
|
35
|
+
* @test
|
|
36
|
+
*/
|
|
31
37
|
export const getRange = (doc, line, column, endLine, endColumn, f = 0, t = Infinity) => {
|
|
32
38
|
const start = pos(doc, line, column, f);
|
|
33
39
|
return {
|
|
@@ -45,8 +51,7 @@ const wikiLintSource = async (wikiLint, text, opt, doc, f = 0, t) => (await wiki
|
|
|
45
51
|
apply(view) {
|
|
46
52
|
view.dispatch({
|
|
47
53
|
changes: {
|
|
48
|
-
|
|
49
|
-
to: posToIndex(doc, range.end),
|
|
54
|
+
...getRange(doc, range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1, f, t),
|
|
50
55
|
insert: newText,
|
|
51
56
|
},
|
|
52
57
|
});
|
|
@@ -56,6 +61,10 @@ const wikiLintSource = async (wikiLint, text, opt, doc, f = 0, t) => (await wiki
|
|
|
56
61
|
? getRange(doc, r.start.line + 1, r.start.character + 1, r.end.line + 1, r.end.character + 1, f, t)
|
|
57
62
|
: { from: from + f, to: (to ?? from) + f },
|
|
58
63
|
}));
|
|
64
|
+
/**
|
|
65
|
+
* @implements
|
|
66
|
+
* @test
|
|
67
|
+
*/
|
|
59
68
|
export const getWikiLintSource = (articlePath) => async (opt, v) => {
|
|
60
69
|
const options = { ...await getOpt(opt), cdn: base.CDN };
|
|
61
70
|
if (articlePath) {
|
|
@@ -98,6 +107,10 @@ const jsLintSource = (esLint, code, opt, doc, f = 0, t) => esLint(code, opt)
|
|
|
98
107
|
}
|
|
99
108
|
return diagnostic;
|
|
100
109
|
});
|
|
110
|
+
/**
|
|
111
|
+
* @implements
|
|
112
|
+
* @test
|
|
113
|
+
*/
|
|
101
114
|
export const getJsLintSource = async (opt) => {
|
|
102
115
|
const { CDN } = base, esLint = await getJsLinter(CDN && `${CDN}/${eslintRepo}`);
|
|
103
116
|
const lintSource = async ({ doc }) => jsLintSource(esLint, doc.toString(), await getOpt(opt), doc);
|
|
@@ -132,12 +145,20 @@ const cssLintSource = async (styleLint, code, opt, doc, f = 0, t) => {
|
|
|
132
145
|
return diagnostic;
|
|
133
146
|
});
|
|
134
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* @implements
|
|
150
|
+
* @test
|
|
151
|
+
*/
|
|
135
152
|
export const getCssLintSource = async (opt) => {
|
|
136
153
|
const { CDN } = base, styleLint = await getCssLinter(CDN && `${CDN}/${stylelintRepo}`);
|
|
137
154
|
const lintSource = async ({ doc }) => cssLintSource(styleLint, doc.toString(), await getOpt(opt), doc);
|
|
138
155
|
lintSource.fixer = async (doc, rule) => styleLint.fixer(doc.toString(), rule);
|
|
139
156
|
return lintSource;
|
|
140
157
|
};
|
|
158
|
+
/**
|
|
159
|
+
* @implements
|
|
160
|
+
* @test
|
|
161
|
+
*/
|
|
141
162
|
export const getVueLintSource = async (opt) => {
|
|
142
163
|
const { CDN } = base, styleLint = await getCssLinter(CDN && `${CDN}/${stylelintRepo}`), esLint = await getJsLinter(CDN && `${CDN}/${eslintRepo}`);
|
|
143
164
|
return async (state) => {
|
|
@@ -160,6 +181,10 @@ export const getVueLintSource = async (opt) => {
|
|
|
160
181
|
];
|
|
161
182
|
};
|
|
162
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* @implements
|
|
186
|
+
* @test
|
|
187
|
+
*/
|
|
163
188
|
export const getHTMLLintSource = async (opt, view, language) => {
|
|
164
189
|
const vueLintSource = await getVueLintSource(opt), wikiLint = await getWikiLinter({ include: false, ...await getOpt(opt), cdn: base.CDN }, view);
|
|
165
190
|
return async (state) => {
|
|
@@ -171,16 +196,24 @@ export const getHTMLLintSource = async (opt, view, language) => {
|
|
|
171
196
|
];
|
|
172
197
|
};
|
|
173
198
|
};
|
|
199
|
+
/**
|
|
200
|
+
* @implements
|
|
201
|
+
* @test
|
|
202
|
+
*/
|
|
174
203
|
export const getJsonLintSource = () => ({ doc }) => lintJSON(doc.toString())
|
|
175
204
|
.map(({ message, from, to = from, severity }) => ({ message, severity, from, to }));
|
|
205
|
+
/**
|
|
206
|
+
* @implements
|
|
207
|
+
* @test
|
|
208
|
+
*/
|
|
176
209
|
export const getLuaLintSource = async () => {
|
|
177
210
|
const { CDN } = base, luaLint = await getLuaLinter(CDN && `${CDN}/${luacheckRepo}`);
|
|
178
211
|
return async ({ doc }) => (await luaLint(doc.toString()))
|
|
179
|
-
.map(({ line, column, end_column
|
|
212
|
+
.map(({ line, column, end_column, msg: message, severity }) => ({
|
|
180
213
|
source: 'Luacheck',
|
|
181
214
|
message,
|
|
182
215
|
severity: severity === 1 ? 'warning' : 'error',
|
|
183
216
|
from: pos(doc, line, column),
|
|
184
|
-
to: pos(doc, line,
|
|
217
|
+
to: pos(doc, line, end_column + 1),
|
|
185
218
|
}));
|
|
186
219
|
};
|
package/dist/lua.js
CHANGED
|
@@ -4,6 +4,7 @@ import { syntaxTree, LanguageSupport, StreamLanguage, foldService, HighlightStyl
|
|
|
4
4
|
import { snippetCompletion } from '@codemirror/autocomplete';
|
|
5
5
|
import { tags } from '@lezer/highlight';
|
|
6
6
|
import { leadingSpaces, sliceDoc } from './util.js';
|
|
7
|
+
import { getLightHighlightStyle } from './theme.js';
|
|
7
8
|
const map = {
|
|
8
9
|
1: 'constant',
|
|
9
10
|
2: 'function',
|
|
@@ -304,6 +305,10 @@ const map = {
|
|
|
304
305
|
type: 'keyword',
|
|
305
306
|
}),
|
|
306
307
|
], types = new Set(['variableName', 'variableName.standard', 'keyword']), lang = StreamLanguage.define(lua);
|
|
308
|
+
/**
|
|
309
|
+
* @implements
|
|
310
|
+
* @test
|
|
311
|
+
*/
|
|
307
312
|
const source = context => {
|
|
308
313
|
const { state, pos } = context, node = syntaxTree(state).resolveInner(pos, -1);
|
|
309
314
|
if (!types.has(node.name)) {
|
|
@@ -408,28 +413,34 @@ const source = context => {
|
|
|
408
413
|
}
|
|
409
414
|
return null;
|
|
410
415
|
};
|
|
416
|
+
/**
|
|
417
|
+
* @implements
|
|
418
|
+
* @test
|
|
419
|
+
*/
|
|
420
|
+
const fold = ({ doc, tabSize }, start, from) => {
|
|
421
|
+
const { text, number } = doc.lineAt(start);
|
|
422
|
+
if (!text.trim()) {
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
const getIndent = (line) => leadingSpaces(line).replace(/\t/gu, ' '.repeat(tabSize)).length;
|
|
426
|
+
const indent = getIndent(text);
|
|
427
|
+
let j = number, empty = true;
|
|
428
|
+
for (; j < doc.lines; j++) {
|
|
429
|
+
const { text: next } = doc.line(j + 1);
|
|
430
|
+
if (next.trim()) {
|
|
431
|
+
const nextIndent = getIndent(next);
|
|
432
|
+
if (indent >= nextIndent) {
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
empty = false;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return empty || j === number ? null : { from, to: doc.line(j).to };
|
|
439
|
+
};
|
|
411
440
|
const support = [
|
|
441
|
+
getLightHighlightStyle(),
|
|
412
442
|
syntaxHighlighting(HighlightStyle.define([{ tag: tags.standard(tags.variableName), class: 'cm-globals' }])),
|
|
413
443
|
lang.data.of({ autocomplete: source }),
|
|
414
|
-
foldService.of(
|
|
415
|
-
const { text, number } = doc.lineAt(start);
|
|
416
|
-
if (!text.trim()) {
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
const getIndent = (line) => leadingSpaces(line).replace(/\t/gu, ' '.repeat(tabSize)).length;
|
|
420
|
-
const indent = getIndent(text);
|
|
421
|
-
let j = number, empty = true;
|
|
422
|
-
for (; j < doc.lines; j++) {
|
|
423
|
-
const { text: next } = doc.line(j + 1);
|
|
424
|
-
if (next.trim()) {
|
|
425
|
-
const nextIndent = getIndent(next);
|
|
426
|
-
if (indent >= nextIndent) {
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
empty = false;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
return empty || j === number ? null : { from, to: doc.line(j).to };
|
|
433
|
-
}),
|
|
444
|
+
foldService.of(fold),
|
|
434
445
|
];
|
|
435
446
|
export default () => new LanguageSupport(lang, support);
|